WTAD Solutions 3

WTAD Solutions 3(21-30)

 

21 Write a Javascript that changes background color to red if user presses the mouse button.
<html>
<script language=”javascript”>
function fun1()
{
document.body.style.backgroundColor = “red”;
}
</script>
<body id=”mybody”>
<input type=”button” onclick=”fun1()” value=”Click to change Background Color”>
</body>
</html>

 

22 Write a JavaScript function to add two numbers when user presses submit button.
<html>
<script language=”javascript”>
function fun1()
{
var no1 = 10;
var no2 = 20;
var ans = no1 + no2;
alert(“Total is : ” + ans);
}
</script>
<body>
<input type=”button” onclick=”fun1()” value=”Click to Sum two numbers”>
</body>
</html>

 

23 What is the code in HTML so that someone can mail by just clicking on text?

In some sites, we can find that by clicking on the highlighted text, a dialogue box opens through which we can compose mail to the recipient’s address which appears on the “TO:” field.

To provide such a facility using Html, the code which is used is:

<a href=”mailto:someone@email.com”>someone@email.com</a>

For example:

<a href=mailto:rubyjacob.7@gmail.com>Contact us</a>

Using the above code, you can mail by just clicking on the anchored text.

 

 

24 Write a code for create a multiple list in HTML.

To create a list of data using html, the tags used are:

<ul>..</ul> ****For Unordered List

<ol>..</ol> ****For Ordered List

<li>..</li>   ****For listing the data.

For example to display the syllabus for internal exam:

<HTML>

<BODY>

<UL>

<LI>WTAD</LI>

<OL TYPE=”i”>

<LI>CHAPTER 1</LI>

<LI>CHAPTER 2</LI>

<LI>CHAPTER 3</LI>

</OL>

<LI>MIS</LI>

<OL TYPE=”a”>

<LI>CHAPTER 1</LI>

<LI>CHAPTER 2</LI>

<LI>CHAPTER 6</LI>

<LI>CHAPTER 7 (UPTO 7.2)</LI>

</OL>

<LI>DC1</LI>

<OL TYPE=”I”>

<LI>CHAPTER 1</LI>

<LI>CHAPTER 2</LI>

<LI>CHAPTER 3</LI>

</OL>

<LI>OR</LI>

<OL TYPE=”1″>

<LI>BASIC OF OR</LI>

<LI>FORMULATION</LI>

<LI>GRAPHICAL AND SIMPLEX METHOD</LI>

<LI>BIG M & DUAL METHOD</LI>

<LI>REPLACEMENT THEORY</LI>

<LI>GAME THEORY</LI>

<LI>SEQUENTIAL PROBLEM</LI>

<LI>LPP</LI>

<LI>NETWORK DIAGRAM</LI>

</OL>

</UL>

</BODY>

</HTML>

 

Output:

  • WTAD
    1. CHAPTER 1
    2. CHAPTER 2
    3. CHAPTER 3
  • MIS
    1. CHAPTER 1
    2. CHAPTER 2
    3. CHAPTER 6
    4. CHAPTER 7 (UPTO 7.2)
  • DC1
    1. CHAPTER 1
    2. CHAPTER 2
    3. CHAPTER 3
  • OR
    1. BASIC OF OR
    2. FORMULATION
    3. GRAPHICAL AND SIMPLEX METHOD
    4. BIG M & DUAL METHOD
    5. REPLACEMENT THEORY
    6. GAME THEORY
    7. SEQUENTIAL PROBLEM
    8. LPP
    9. NETWORK DIAGRAM

 

 

25 Which two methods are used for takes keyboard input and screen output in Java Script?

There are some methods in JavaScript that takes user input and displays the output.

  1. prompt(): This method is used to take input from the user using a prompt box.
  2. alert(): Used to display the message using alert box.
  3. write():Used to display the data on the body part of a website

 

26 write a javascript to display”Hello World”.

A simple JavaScript program to display “Hello World”:

<html>

<body>

<script>

document.write(“Hello World!”);

</script>

</body>

</html>

 

 

27 what are the major different between doGet() and doPost()?

In Servlet, you can process the data using two methods:

  1. doGet() method
  2. doPost() method

doGet() method is used to process the data by inserting the data values into the URL.

doPost() method is used to process the data by hiding the values from being displayed on the URL.

doGet() is used for small amount of data that is to processed.

doPost() is used to process large amount of data. It secures the data that is to be processed.

DoGet

DoPost

In doGet Method the parameters are appended to the URL and sent along with header information In doPost, parameters are sent in separate line in the body
Maximum size of data that can be sent using doget is 240 bytes There is no maximum size for data
Parameters are not encrypted Parameters are encrypted
DoGet method generally is used to query or to get some information from the server Dopost is generally used to update or post some information to the server
DoGet is faster if we set the response content length since the same connection is used. Thus increasing the performance DoPost is slower compared to doGet since doPost does not write the content length
DoGet should be idempotent. i.e. doget should be able to be repeated safely many times This method does not need to be idempotent. Operations requested through POST can have side effects for which the user can be held accountable, for example, updating stored data or buying items online.
DoGet should be safe without any side effects for which user is held responsible This method does not need to be either safe

 

28 explain ServletResponse.

 

It defines an object to assist a servlet in sending a response to the client.

The servlet container creates a ServletResponse object and passes it as an argument to the servlet’s service method. It acts as an interface between the client and the server for providing the proper response to the client. The sub interface HttpServletResponse uses an object to access the methods to respond to the client.

Eg.

To enable printing data on screen using an object.

PrintWriter out=response.getWriter();

 

29 explain JavaScript Array.

 

30)Explain Web Descriptor(Web.Xml)file.Explain the structure of Web.Xml with sample data.

 

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative