www.onlinecode.in Provided By : Online Code

Page | 1

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. Solution: Web 2.0 is a term that describes the changing trends in the use of World Wide Web technology and Web design that aim to enhance creativity, secure information sharing, increase collaboration, and improve the functionality of the Web as we know it (Web 1.0). These have led to the development and evolution of Web-based communities and hosted services, such as social-networking sites (i.e. Facebook, MySpace), video sharing sites (i.e. YouTube), wikis, blogs (onlinecode) etc. Web 2.0 Websites typically include some of the following features/techniques: • Search: the ease of finding information through keyword searching. • Links: guides to important pieces of information. The best pages are the most frequently linked to. • Authoring: the ability to create constantly updating content that is co-created by users. In wikis, the content is iterative in the sense that the people undo and redo each other’s work. In blogs, it is cumulative in that posts and comments of individuals are accumulated over time. • Tags: categorization of content by creating tags that are simple, one-word descriptions to facilitate searching and avoid having to fit into rigid, pre-made categories. • Extensions: automation of pattern matching for customization by using algorithms (i.e. Amazon.com recommendations). • Signals: the use of RSS (Real Simple Syndication) technology to create a subscription model which notifies users of any content changes.

1. (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, SemiUrban, Rural), proposed user name and password, and a SUBMIT button. You must perform validations using JavaScript.

Solution:

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code anyform

REGISTRATION FORM

FIRST NAME
LAST NAME
DATE OF BIRTH
email ID
EMPLOYMENT STATUS YES|| NO
LOCALITY
PASSWORD


Prepared by : IGNOU ROCK

Page | 3

www.onlinecode.in Provided By : Online Code

Page | 4

This error detected, because the last name is blank before click the submit button.

1. (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 color 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. IV. Also show how CSS can change the display format. Solution bca:bcs53Q1(c)

ABOUT SCHOOL

A school is an institution designed to provide learning spaces and learning environments for the teaching of students (or "pupils") under the direction of teachers. Most countries have systems of formal education, which is commonly compulsory.[citation needed] In these systems, students progress through a series of schools. The names for these schools vary by country (discussed in the Regional section below) but generally include primary school for young children and secondary school for teenagers who have completed primary education. An institution where higher education is taught, is commonly called a university college or university.

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code
In addition to these core schools, students in a given country may also attend schools before and after primary and secondary education. Kindergarten or pre-school provide some schooling to very young children (typically ages 3–5). University, vocational school, college or seminary may be available after secondary school. A school may also be dedicated to one particular field, such Page | 5 as a school of economics or a school of dance. Alternative schools may provide non-traditional curriculum and methods. There are also non-government schools, called private schools.


1. (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.

Solution:

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:

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code publication = element publication { pubtitle, title, author+, publisher, publication-typespecific, serial }

edition,

volume,

refdate,

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, shortrefdate, edition?, volume?, publisher?, serial? } datafile-publication = element publication { pubtitle }

XML Document

Learning .NEt Windows Erik T. Ray R.Puteam 2003 399.95 Everyday Italian Giada De Laurentiis R.Puteam 2005 330.00 Harry Potter J K. Rowling R.Puteam 2005 829.99 XQuery Kick Start James McGovern Per Bothner Kurt Cagle James Linn Vaidyanathan Nagarajan R.Puteam 2003 249.99 Learning XML Erik T. Ray R.Puteam 2003 397.95

DTD

Prepared by : IGNOU ROCK

title,

author+,

Page | 6

www.onlinecode.in Provided By : Online Code ]>

1. (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. Solution:
Ready For Assignment


Prepared by : IGNOU ROCK

Page | 7

www.onlinecode.in Provided By : Online Code

Page | 8

The text color changing every sec. 1. (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. Solution: 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 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 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:

This is the first card in the deck

Ths is the second card in the deck



Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code
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. Page | 9 Solution:

Static websites

Dynamic websites

Static websites contain fixed number of pages.

Dynamic websites can create webpage dynamically.

Theme of website and content of webpage are Webpage design and content may change on run fixed. time. Static websites load quickly on client browser Dynamic sites take some time to load on client because it has only some markup contents. browser because it processes the request server side and create contents dynamically. Static sites never use database connectivity. Dynamic sites deal with database and generate the contents dynamically using database queries. Static websites is highly secure than dynamic sites because it behaves as a half duplex approach so only one way communication is possible i.e. server to client. Static site use for provide some information to the clients like an organization or institute website. Static website directly run on browser and does not require other server application language. Static website can be created from HTML and CSS. Static sites are easy to develop and a bit experienced people can develop it.

In static website if we want to change the page content then we have to upload that page on server many times.

Dynamic sites are less secure because it behaves as full duplex approach so both side communications is possible so user can change the server data. Dynamic website use where content changes frequently on run time. Like a E-commerce site, online examination, etc. Dynamic website run the application on server and the output will display on webpage. So this is require server application language like PHP , Asp.NET, JSP etc. Dynamic websites not easy to develop because require qualify developers to create it, manage it, test it and maintain security of application and database. Dynamic sites provide the facilities that it possible to change the page content using server application. And need not to upload the page on server.

MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards. The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code

BACK button/Reloa d Bookmarked

GET Harmless

Can be bookmarked

Cached Can be cached Encoding type application/x-www-form-urlencoded

History

Parameters remain in browser history

POST Data will be re-submitted (the browser should alert the user that the data are about to be re-submitted) Page | Cannot be bookmarked 10 Not cached application/x-www-formurlencoded or multipart/form-data. Use multipart encoding for binary data Parameters are not saved in browser history

Restrictions Yes, when sending data, the GET No restrictions on data method adds the data to the URL; and length the length of a URL is limited (maximum URL length is 2048 characters) Restrictions on data type

Only ASCII characters allowed

Security

GET is less secure compared to POST POST is a little safer than because data sent is part of the URL GET because the parameters are not stored in browser history or in web server logs Never use passwords information!

Visibility

GET when or other

No restrictions. Binary data is also allowed

sending sensitive

Data is visible to everyone in the URL

Data is not displayed in the URL

2. (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 Solution: (i)

Page Directive :- The page directive is used to provide instructions to the

container that pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page. Following is the basic syntax of page directive: <%@ page attribute="value" %>

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code (ii)

Scriptlet code :- A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.

Following is the syntax of Scriptlet: <% code fragment %>

(iii)

:- The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.

The getProperty action has only two attributes, both of which are required ans simple syntax is as follows: ...

(iv)

:- The tag allows proper URL request parameter to be specified with URL and it does any necessary URL encoding required.

Within a tag, the name attribute indicates the parameter name, and the value attribute indicates the parameter value:

(v)

Request and Response objects :(a) The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page the JSP engine creates a new object to represent that request. (b) The response object is an instance of a javax.servlet.http.HttpServletResponse object. Just as the server creates the request object, it also creates an object to represent the response to the client. 2 (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 not match then display a message “Username or password is not valid” else the following message is displayed “Welcome ”. Soluiton

Prepared by : IGNOU ROCK

Page | 11

www.onlinecode.in Provided By : Online Code HTTP protocol and Web Servers are stateless, what it means is that for web server every request is a new request to process and they can’t identify if it’s coming from client that has been sending request previously. But sometimes in web applications, we should know who the client is and process the request accordingly. For example, a shopping cart application should know who is sending the request to add an item and in which cart the item has to be added or who is sending checkout request so that it can charge the amount to correct client. That’s why we need Session Management . Index.html TODO supply a title

Login Page

Hello World!

Login to App

Prepared by : IGNOU ROCK

Page | 12

www.onlinecode.in Provided By : Online Code
User ID
Password
Page | 13

LoginServlet.java /* To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* @author Aashi */ //package com.amzi.servlets; importjava.io.IOException; importjava.io.PrintWriter; importjavax.servlet.RequestDispatcher; importjavax.servlet.ServletException; importjavax.servlet.http.HttpServlet; importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; importjavax.servlet.http.HttpSession; //import com.amzi.dao.LoginDao; public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter();

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

HttpSession session = request.getSession(false);

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code if(session!=null) session.setAttribute("name", n); if(LoginDao.validate(n, p)){ RequestDispatcherrd=request.getRequestDispatcher("welcome.jsp"); Page | 14

rd.forward(request,response); } else{ out.print("

Sorry username or password error

"); RequestDispatcherrd=request.getRequestDispatcher("index.jsp"); rd.include(request,response); } out.close(); } } LoginDao.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* @author Aashi */ //package com.amzi.dao; importjava.sql.Connection; importjava.sql.DriverManager; importjava.sql.PreparedStatement; importjava.sql.ResultSet; importjava.sql.SQLException;

public class LoginDao { public static boolean validate(String name, String pass) { boolean status = false; Connection conn = null; PreparedStatementpst = null; ResultSetrs = null;

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code String url = "jdbc:mysql://localhost:3306/"; String dbName = "form"; String driver = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "password"; try { Class.forName(driver).newInstance(); conn = DriverManager .getConnection(url + dbName, userName, password);

pst = conn .prepareStatement("select * from login where UserName=? and password=?"); pst.setString(1, name); pst.setString(2, pass);

rs = pst.executeQuery(); status = rs.next();

} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException e) { System.out.println(e); } finally { if (conn != null) { try { conn.close(); } catch (SQLException e) { } } if (pst != null) { try { pst.close(); } catch (SQLException e) { } }

Prepared by : IGNOU ROCK

Page | 15

www.onlinecode.in Provided By : Online Code if (rs != null) { try { rs.close(); } catch (SQLException e) { Page | 16

} } } return status; } } Welcome.jsp <%-Document

: Welcome

Created on : Sep 20, 2016, 11:39:41 PM Author

: Aashi

--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%> JSP Page

Login successful!!!

Hello,<%=session.getAttribute("UserName")%>

2 (d) Assume that you have a database of the accounts of the students of a University in a local bank. The database fields include account number, name, phone number, address, and balance. Write a program using JSP which displays all the details of the accounts whose balance is less than 100 Rupees. Solution: Here, we are going to create the simple example to create the login form using servlet. We have

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code used oracle10g as the database. There are 5 files required for this application. o

index.html

o

FirstServlet.java

o

AccountDao.java

o

SecondServlet.java

o

web.xml

Page | 17

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: 1. create table userreg(name varchar2(40),pass varchar2(40)); index.html 1.
2. Enter Account Number:

3. 4.
FirstServlet.java import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class FirstServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 14. response.setContentType("text/html"); PrintWriter out = response.getWriter(); String n=request.getParameter("accountno"); if(AccountDao.validate(n)){ RequestDispatcher rd=request.getRequestDispatcher("servlet2"); rd.forward(request,response); } else{ out.print("Sorry account number error"); RequestDispatcher rd=request.getRequestDispatcher("index.html");

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code rd.include(request,response); } 30. out.close(); }

Page | 18

} AccountDao.java 1. import java.sql.*; 2. public class AccountDao { public static boolean validate(String accountno){ boolean status=false; try{ Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","oracle"); PreparedStatement ps=con.prepareStatement( "select * from Account where accountno=? and balance>100"); ps.setString(1, accountno); ResultSet rs=ps.executeQuery(); status=rs.next(); }catch(Exception e){System.out.println(e);} return status; } } WelcomeServlet.java import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class WelcomeServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter();

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : Online Code ResultSet rs=ps.executeQuery(); While(rs.next()) { String accountno =request.getParameter("accountno"); String name =request.getParameter("name"); String phonenumber =request.getParameter("phonenumber"); String address =request.getParameter("address"); String balcance =request.getParameter("balcance"); out.print("Accout Nnumber"+ accountno+”\t”); out.print("Name"+ name+”\t”); out.print("Phone Nnumber"+ phonenumber+”\t”); out.print("Address"+ address+”\t”); out.print("Balance"+ balcance+”\t”); out,println(); } out.close(); } }

Prepared by : IGNOU ROCK

Page | 19

BCS-053.pdf

Page 1 of 19. www.onlinecode.in. Provided By : Online Code. Prepared by : IGNOU ROCK. Page | 1. 1. (a) List important technologies of Web 2.0. Explain the ...

986KB Sizes 11 Downloads 176 Views

Recommend Documents

No documents