Ignou Study Helper sunilpoonia006.blogspot.com

BCS 053 july 2016-january 2017 session 1. (covers Block 1) (a) List important technologies of Web 2.0. Explain the term Mashups in the context of Web 2.0 with the help of an example. List the process of creating a Mashup. Ans. Web 2.0 describes World Wide Web websites that emphasize user-generated content, usability (ease of use, even by non-experts), and interoperability (this means that a website can work well with other products, systems and devices) for end users. The term was popularized by Tim O'Reilly and Dale Dougherty at the O'Reilly Media Web 2.0 Conference in late 2004, though it was coined by Darcy DiNucci in 1999. Web 2.0 does not refer to an update to any technical specification, but to changes in the way Web pages are made and used.

rr e p l e e p l H e y H d y u t d S u t uu S o n g IIgno

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 the first generation of Web 1.0-era websites where people were limited to the passive viewing of content. Examples of Web 2.0 include social networking sites and social media sites (e.g.,Facebook), blogs, wikis, folksonomies ("tagging" of websites and links), video sharing sites (e.g., YouTube), hosted services,Web applications ("apps"), collaborative consumption platforms, and mashup applications, that allow users to blend the digital audio from multiple songs together to create new music. Whether Web 2.0 is substantively different from prior Web technologies has been challenged by World Wide Web inventor Tim Berners-Lee, who describes the term as jargon. His original vision of the Web was "a collaborative medium, a place where we [could] all meet and read and write". On the other hand, the term Semantic Web (sometimes referred to as Web 3.0)[citation needed] was coined by Berners-Lee to refer to a web of data that can be processed by machines

(b) Create a simple Registration form consisting of the following information – First and Last Name, date of birth (it should be validated), email ID (it should be validated), Employment status (Yes or No), Locality (to be selected from drop down list of Metropolitan, Urban, Semi-Urban, Rural), proposed user name and password, and a SUBMIT button. You must perform validations using JavaScript. Ans. Update soon http://www.ignouassignmentguru.com

(c) Create a simple web page using HTML consisting of two paragraphs about your School. Both the paragraphs should be created in different divisions. You must also create an external CSS file which ensures the following: (i) The first paragraph should use font Arial. The background of this paragraph should be light yellow and text colour green. (ii) The second paragraph should have light green background and text colour as blue. (iii) Both the paragraphs should have one heading which should have same format in both the paragraphs. Also show how CSS can change the display format. Ans. Update soon http://www.ignouassignmentguru.com

r e lp

e H

(d) A Library maintains detailed record of its books using XML. Every book has a unique book procurement number. A book has a Title, one or more authors, a publisher, year of publication, price, and an optional abstract. Create an XML documents containing information of five such Books. Also create the DTD for the XML Books document.

y d

Ans. The element library

u o n

u t S

The element library defines all elements that particular reference types might want to store in a database. This is reasonably easy for a database programmer to translate into a database schema which can hold all the required information. But how does RelaxNG help the reference data author to fill in the required data? Let's look at some examples. Most reference types require the publication element (the element that holds monographic data). The following definition in rbib-library.rnc defines the superset of all elements that might ever end up in the publication element:

Ig

publication = element publication { pubtitle, title, author+, edition, volume, refdate, publisher, publication-typespecific, serial }

Some "elements" like publication-typespecific and refdate are named patterns which in turn consist of several XML elements, but don't let yourself get distracted by this. Now let's have a look at two reference types that use the publication element in different ways: book-publication = element publication { pubtitle, title, author+, shortrefdate, edition?, volume?, publisher?, serial? }

/IGNOUASSIGNMENTGURU

datafile-publication = element publication { pubtitle }

You certainly didn't miss that the publication element of the datafile reference type is allowed to hold only one element - the title. If you try to add anything else, the dataset will be invalid and you'll immediately see that you've added all required info. On the other hand, the publication element of the book reference type allows additional elements, but not all that are available in the library - it is just a different selection from what's available. This way, a validating XML editor can guide you through each entry and help you add whatever is required (and allowed) for a particular reference type. Another advantage of the use of RelaxNG patterns is that reference types can share parts of their structure, or even the complete structure, thus reducint the bloat of the schema. In the latter case, the different data types are used only to record the nature of the reference. E.g. the journalarticle and journalabstract types share exactly the same structure. But as some journals insist on formatting paper and abstract references differently, we have to record the nature of the reference. We can't infer it from the structure. Reference data types

y d

r e lp

e H

As said previously, rbib builds on RIS and currently offers the reference types that RIS supports (with a few exceptions, see below). I've currently refrained from including additional types, although a few of them should be added lateron. The design of the schema allows the assembly of custom types from the available pool of elements.

u o n

Analytical types

u t S

Ig

The following data types use analytical information at the lowest level:

/IGNOUASSIGNMENTGURU

Monographic types

y d

r e lp

e H

The following data types use monographic information at the lowest level:

u o n

u t S

Ig

/IGNOUASSIGNMENTGURU

(e) Write a script using JavaScript that changes the content of a title – First Assignment to the title – Ready for Assignment. The script should change the colour of the content Ready for Assignment after every 4 seconds. Make suitable assumptions, if any.

Ans. This first example will create a new positioned element as a child of the document. if( document.layers && window.Layer && document.classes ) { //create a layer 350px wide document.layers['newName'] = new Layer( 350 ); //write its content document.layers['newName'].document.open(); document.layers['newName'].document.write('new content');

r e lp

document.layers['newName'].document.close(); //style it document.layers['newName'].left = 0;

y d

document.layers['newName'].top = 0;

u t S

document.layers['newName'].visibility = 'show'; } else if( document.body ) {

u o n

e H

var theString = '
new content
';

Ig

if( document.body.insertAdjacentHTML ) { document.body.insertAdjacentHTML( 'beforeEnd', theString ); } else if( typeof( document.body.innerHTML ) != 'undefined' ) { document.body.innerHTML += theString; } else { //FAILURE, nothing works } } else { //FAILURE, nothing works }

/IGNOUASSIGNMENTGURU

Th next example will create a new positioned element as a child of an existing positioned element (myReference is obtained as above): if( document.layers && window.Layer && document.classes ) { //create a layer 350px wide document.layers['newName'] = new Layer( 350, myReference ); //write its content document.layers['newName'].document.open(); document.layers['newName'].document.write('new content'); document.layers['newName'].document.close(); //style it document.layers['newName'].left = 0;

r e lp

document.layers['newName'].top = 0; document.layers['newName'].visibility = 'show'; } else {

y d

var theString = '
new content
';

u o n

e H

if( myReference.insertAdjacentHTML ) {

myReference.insertAdjacentHTML( 'beforeEnd', theString );

Ig

} else if( typeof( myReference.innerHTML ) != 'undefined' ) { myReference.innerHTML += theString; } else { //FAILURE, nothing works } } Test it here: create a new element (new elements will alternate in colour and will be slightly offset from each other to make it more easy to see what is happening). This is the original content of the existing positioned element. It will not be changed. Changing the background colour of the whole document

/IGNOUASSIGNMENTGURU

Opera 5, OmniWeb 4.2- and Escape/Evo cannot change the background colour of the document (Escape will change the background colour, but only at the very end of the document, after all of the content). Opera 6 and Clue browser will only change the colour behind the content, the original background colour will remain where the content is smaller than the window. NetFront 3.3- will allow you to set the colour to '', but will not show any change until you scroll. There are three ways to change the background colour. Old browsers use the bgColor property to style the background of the entire document. In current browsers, the HTML element and the BODY element are rendered separately, by default with the HTML element taking up just a few pixels outside the BODY. They are able to be styled separately, so to change the document background, both of them need to be changed. The HTML element is referenced in these browsers as document.documentElement, and the BODY is referenced as document.body. Setting the wrong one will not cause errors (as long as they exist), so I set all of them at the same time. if( document.documentElement && document.documentElement.style ) {

r e lp

document.documentElement.style.backgroundColor = 'red'; } if( document.body && document.body.style ) { document.body.style.backgroundColor = 'red'; }

y d

document.bgColor = 'red';

u t S

e H

Test it here: change the background colour of this document to: #f6f6f6

u o n

#d2cbff

Ig

#777777

'' (returns to default) - not allowed by some old browsers Changing the display style of any element WebTV does not support the display style. Older browsers such as Netscape 4, Escape 4, Opera 6-, OmniWeb 4.2-, NetFront 3.2- and Clue browser support the display: none; style, but do not allow JavaScript to change it. See the guidelines below. iCab 2- sometimes makes mistakes with rendering when changing the display style and interprets 'block' as 'return to default'. Many device browsers will ignore the display style when in small screen reformatting mode. Internet Explorer 4 on Windows does not understand inline display. Escape 4 does actually allow you to change the display style (only block, inline and none accepted) using the style object, but only on layers and ilayers. Since the best use of the display style is for unpositioned

/IGNOUASSIGNMENTGURU

elements, and considering that changing from none to inline or block has no effect in Escape until the window is resized, i do not recommend even attempting it. (f) Explain any five Formatting and Link elements in WML with the help of an example each. Create a simple WML program that should ask for an input from a list of options. Ans.The topmost layer in the WAP (Wireless Application Protocol) architecture is made up of WAE (Wireless Application Environment), which consists of WML and WML scripting language.





WML stands for Wireless Markup Language



WML is based on HDML and is modified so that it can be compared with HTML.



WML is the markup language defined in the WAP specification.



WML is very similar to HTML. Both of them use tags and are written in plain text format.



WML is an application of XML, which is defined in a document-type definition.



WML takes care of the small screen and the low bandwidth of transmission.



WAP sites are written in WML, while web sites are written in HTML.

r e lp

WML files have the extension ".wml". The MIME type of WML is "text/vnd.wap.wml".

 WML supports client-side scripting. The scripting language supported is called WMLScript. WML Program Structure: Following is the basic structure of a WML program:

y d

This is the first card in the deck



u o n

u t S

e H

Ig

Ths is the second card in the deck



2. (Covers Block 2) (a) Differentiate between Static and Dynamic websites. How does MVC help in creating dynamic websites? Explain with the help of an example. Also differentiate between GET and POST methods of HTTP.

Ans. In simplest terms, static Web pages are those with content that cannot change without a developer editing its source code, while dynamic Web pages can display different content from the same source code. When it comes to using static or dynamic pages for parts of your company's website,

/IGNOUASSIGNMENTGURU

having the most advanced code on each of your pages is not important. What is important is the purpose each page serves for your website. Static Web Pages Static Web pages display the exact same information whenever anyone visits it. Static Web pages do not have to be simple plain text. They can feature detailed multimedia design and even videos. However, every visitor to that page will be greeted by the exact same text, multimedia design or video every time he visits the page until you alter that page's source code. Dynamic Web Pages Dynamic Web pages are capable of producing different content for different visitors from the same source code file. The website can display different content based on what operating system or browser the visitor is using, whether she is using a PC or a mobile device, or even the source that referred the visitor. A dynamic Web page is not necessarily better than a static Web page. The two simply serve different purposes.

r e lp

Dynamic Page Use

Dynamic pages can serve a variety of purposes. For example, websites run by content management systems allow a single source code file to load the content of many different possible pages. Content creators use a gateway page to submit the material for new pages into the CMS' database. The dynamic page can then load the material for any page in the database, based on parameters in the URL with which a visitor requests the page. Dynamic pages are also what let users log into websites to see personalized content.

y d

Static vs Dynamic Creation

u o n

u t S

e H

Developers generally create static pages with HTML, but use languages like PHP, Javascript, or Actionscript to create dynamic pages. They can also use frameworks like Ruby on Rails, Django, or Flex for dynamic pages. Dynamic languages and frameworks also have the technical capacity to create static Web page content. However, doing so creates source code that is unnecessarily complex for its purpose while being more difficult to maintain.

Ig

(b) Explain the following in the context of JSP with the help of an example. (i) page Directive (ii) scriptlet code (iii) (iv) (v) Request and Response objects Ans. (I) PAGE DIRECTIVE

/IGNOUASSIGNMENTGURU

1. JSP directives 1. page directive 2. Attributes of page directive The jsp directives are messages that tells the web container how to translate a JSP page into the corresponding servlet. There are three types of directives: o

page directive

o

include directive

o

taglib directive

import

r e lp

The import attribute is used to import class,interface or all the members of a package.It is similar to import keyword in java class or interface.

Example of import attribute

y d

1. 2. 3.

u o n

u t S

e H

4. <%@ page import="java.util.Date" %> 5. Today is: <%= new Date() %> 6.

Ig

7. 8.

(II) SCRIPTLET CODE In JSP, java code can be written inside the jsp page using the scriptlet tag. Let's see what are the scripting elements first.

JSP Scripting elements The scripting elements provides the ability to insert java code inside the jsp. There are three types of scripting elements: o

scriptlet tag

o

expression tag

/IGNOUASSIGNMENTGURU

o

declaration tag

JSP scriptlet tag A scriptlet tag is used to execute java source code in JSP. Syntax is as follows: 1. <% java source code %>

Example of JSP scriptlet tag In this example, we are displaying a welcome message. 1. 2. 3. <% out.print("welcome to jsp"); %> 4.

r e lp

5.

(iii)

e H

The setProperty and getProperty action tags are used for developing web application with Java Bean. In web devlopment, bean class is mostly used because it is a reusable software component that represents data.

y d

u t S

The jsp:setProperty action tag sets a property value or values in a bean using the setter method.

u o n

Syntax of jsp:setProperty action tag

1.
|

Ig

2. property="propertyName" param="parameterName" | 3. property="propertyName" value="{ string | <%= expression %>}" 4. />

(iv) there are many JSP action tags or elements. Each JSP action tag is used to perform some specific tasks. The action tags are used to control the flow between pages and to use Java Bean. The Jsp action tags are given below.

JSP Action Tags Description jsp:forward

forwards the request and response to another resource.

/IGNOUASSIGNMENTGURU

jsp:include

includes another resource.

jsp:useBean

creates or locates bean object.

jsp:setProperty

sets the value of property in bean object.

jsp:getProperty

prints the value of property of the bean.

jsp:plugin

embeds another components such as applet.

jsp:param

sets the parameter value. It is used in forward and include mostly.

jsp:fallback

can be used to print the message if plugin is working. It is used in jsp:plugin.

(V)Request And Response Objects

r e lp

There are 9 jsp implicit objects. These objects are created by the web container that are available to all the jsp pages.

e H

The available implicit objects are out, request, config, session, application etc.

y d

A list of the 9 implicit objects is given below:

Object out

Type

request

ou

n g I

response

u t S

JspWriter

HttpServletRequest

HttpServletResponse

config

ServletConfig

application

ServletContext

session

HttpSession

pageContext

PageContext

page

Object

exception

Throwable

/IGNOUASSIGNMENTGURU

(C) What is the need of Session management in HTTP? Explain with the help of an example. Create a simple form consisting of two user input fields – username and password. Check these username and password from a database (consisting of username, password and name of account holder) using JSP/Servlet. In case the username or password does ot atch the display a essage User a e or password is not alid else the follo i g essage is displayed Welco e . Ans. Here, we are going to create the simple example to create the login form using servlet. We have used oracle10g as the database. There are 5 files required for this application. o

index.html

o

FirstServlet.java

o

LoginDao.java

o

SecondServlet.java

o

web.xml

r e lp

e H

You must need to create a table userreg with name and pass fields. Moreover, it must have contained some data. The table should be as:

y d

u t S

1. create table userreg(name varchar2(40),pass varchar2(40));

u o n

index.html

1.


2. Name:



Ig

3. Password:

4. 5.


FirstServlet.java 1. import java.io.IOException; 2. import java.io.PrintWriter; 3. 4. import javax.servlet.RequestDispatcher; 5. import javax.servlet.ServletException; 6. import javax.servlet.http.HttpServlet; 7. import javax.servlet.http.HttpServletRequest; 8. import javax.servlet.http.HttpServletResponse; 9. 10. 11. public class FirstServlet extends HttpServlet {

/IGNOUASSIGNMENTGURU

12. public void doPost(HttpServletRequest request, HttpServletResponse response) 13.

throws ServletException, IOException {

14. 15.

response.setContentType("text/html");

16.

PrintWriter out = response.getWriter();

17. 18.

String n=request.getParameter("username");

19.

String p=request.getParameter("userpass");

20. 21.

if(LoginDao.validate(n, p)){

22.

RequestDispatcher rd=request.getRequestDispatcher("servlet2");

23.

rd.forward(request,response);

24.

}

25.

else{

r e lp

26.

out.print("Sorry username or password error");

27.

RequestDispatcher rd=request.getRequestDispatcher("index.html");

28.

rd.include(request,response);

29.

}

30. 31.

out.close();

32.

}

y d

33. } LoginDao.java

u o n

1. import java.sql.*; 2.

u t S

e H

Ig

3. public class LoginDao {

4. public static boolean validate(String name,String pass){ 5. boolean status=false; 6. try{

7. Class.forName("oracle.jdbc.driver.OracleDriver"); 8. Connection con=DriverManager.getConnection( 9. "jdbc:oracle:thin:@localhost:1521:xe","system","oracle"); 10. 11. PreparedStatement ps=con.prepareStatement( 12. "select * from userreg where name=? and pass=?"); 13. ps.setString(1,name); 14. ps.setString(2,pass); 15. 16. ResultSet rs=ps.executeQuery(); 17. status=rs.next();

/IGNOUASSIGNMENTGURU

18. 19. }catch(Exception e){System.out.println(e);} 20. return status; 21. } 22. } WelcomeServlet.java 1. import java.io.IOException; 2. import java.io.PrintWriter; 3. 4. import javax.servlet.ServletException; 5. import javax.servlet.http.HttpServlet; 6. import javax.servlet.http.HttpServletRequest; 7. import javax.servlet.http.HttpServletResponse; 8.

r e lp

9. public class WelcomeServlet extends HttpServlet {

10. public void doPost(HttpServletRequest request, HttpServletResponse response) 11.

throws ServletException, IOException {

12. 13.

response.setContentType("text/html");

14.

PrintWriter out = response.getWriter();

15.

u t S

y d

16.

String n=request.getParameter("username");

17.

out.print("Welcome "+n);

u o n

18. 19.

out.close();

20.

}

21. 22. }

e H

Ig

/IGNOUASSIGNMENTGURU

BCS-053.pdf

Examples of Web 2.0. include social networking sites and social media sites (e.g.,Facebook), blogs, wikis, folksonomies. ("tagging" of websites and links), video ...

732KB Sizes 3 Downloads 194 Views

Recommend Documents

No documents