Friday, December 30, 2016

Series

Write a program print series.
1. 1 3 6 10 15
2. 2 4 7 11  16



void main()
{
int i,j=1;//same java,c,c++
for(int i=1;i<=5;i++)
{
j=j+i;
printf("%d",j);//c program
System.out.println(j);//java
cout<<j;//c++
}


}
2.
void main()
{
int i,j=0;//same java,c,c++
for(int i=1;i<=5;i++)
{
j=j+i;
printf("%d",j);//c program
System.out.println(j);//java
cout<<j;//c++
}


}

Wednesday, December 28, 2016

what is the difference between div and span tags


DIV TAG:

Following are the characteristics:
  1. As the name indicates, the div tag defines a ‘division’ in a web page.
  2. div is a block-element; its default display value is “block”.
  3. div tag is commonly used while creating Css based layouts in html.
  4. by default, a line-break is placed before and after this element.

SPAN TAG:

Following are the characteristics:
  1. span tag makes no visual difference in the page, unless customised with style attribute.
  2. span is an in-line element.
  3. span is commonly used to stylize texts. The in-line feature makes it easy to use custom styles without changing the layout.
  4. No line-breaks by default, but this can be achieved if we change its in-line nature by specifying in the style attribute to ‘display:block;’

Scalable Vector Graphics.

SVG stands for Scalable Vector Graphics.
SVG defines vector-based graphics in XML format.






<!DOCTYPE html>
<html>
<body>

<h1>My first SVG</h1>

<svg width="100" height="100">
   <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
   Sorry, your browser does not support inline SVG.
</svg> 

</body>
</html>




<!DOCTYPE html>
<html>
<body>

<svg width="400" height="110">
  <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)">
  Sorry, your browser does not support inline SVG.
</svg>

</body>
</html>


Why use SVG at all?

  • Small file sizes that compress well
  • Scales to any size without losing clarity (except very tiny)
  • Looks great on retina displays
  • Design control like interactivity and filters

<!DOCTYPE html>
<html>
<body>

<svg width="400" height="180">
  <rect x="50" y="20" rx="20" ry="20" width="150" height="150" style="fill:red;stroke:black;stroke-width:5;opacity:0.5">
  Sorry, your browser does not support inline SVG.
</svg>

</body>
</html>


1) What is HTML?

HTML stands for Hyper Text Markup Language. It is a language of World Wide Web. It is a standard text formatting language which is used to create and display pages on the Web. 

2) What are Tags?

HTML tags are composed of three things: opening tag, content and ending tag. Some tags are unclosed tags.
HTML documents are made of two things:
  • content, and
  • tags
Content is placed between tags to display data on the web page.

3) Do all HTML tags have end tag?

No. There are some HTML tags that don't need a closing tag. For example: <image> tag, <br> tag. 

4) What are some common lists that are used when designing a page?

There are many common lists which are used to design a page. You can choose any or a combination of the following list types:
  • Ordered list
  • Unordered list
  • Menu list
  • Directory list
  • Definition list

6) What is semantic HTML?

Semantic HTML is a coding style. It is the use of HTML markup to reinforce the semantics or meaning of the content. For example: In semantic HTML <b> </b> tag is not used for bold statement as well as <i> </i> tag is used for italic. Instead of these we use <strong></strong> and <em></em> tags.

7) What is image map?

Image map facilitates you link many different web pages using a single image. You can define shapes in images that you want to make part of an image mapping.

8) How to insert a copyright symbol on a browser page?

can insert a copyright symbol by using &copy; or &#169; in an HTML file.

9) How do you keep list elements straight in an HTML file?

You can keep the list elements straight by using indents.

10) Does a hyperlink only apply to text?

No, you can use hyperlinks on text and images both. 

11) What is a style sheet?

A style sheet is used to build a consistent, transportable, and well designed style template. You can add these templates on several different web pages.

12) Can you create a multi colored text on a web page?

Yes. To create a multicolor text on a web page you can use <font color ="color"> </font> for the specific texts you want to color.

13) Is it possible to change the color of the bullet?

The color of the bullet is always the color of the first text of the list. So, if you want to change the color of the bullet, you must change the color of the text.

14) What is a marquee?

Marquee is used to put the scrolling text on a web page. You should put the text which you want to scroll within the <marquee>......</marquee> tag.


15) How many tags can be used to separate section of texts?

There are three tags used to separate the texts. i.e. usually <br> tag is used to separate line of texts. Other tags are<p> tag and <blockquote> tag.

16) How to make a picture a background image of a web page?

To make a picture a background image on a web page, you should put the following tag code after the </head> tag.
  1. <body background = "image.gif">  
Here, replace the "image.gif" with the name of your image file which you want to display on your web page.

17) What are empty elements?

HTML elements with no content are called empty elements. For example: <br>, <hr> etc.

18) What is the use of span tag? Give one example.

The span tag is used for following things:
  • For adding color on text
  • For adding background on text
  • Highlight any color text etc.
Example:
  1. <p>  
  2. <span style="color:#ffffff;">  
  3. In this page we use span.  
  4. </span>  
  5. </p>  

19) What is the use of iframe tag?

An iframe is used to display a web page within a web page.
Syntax:
  1. <iframe src="URL"></iframe>  
Example:
  1. <iframe src="demo_iframe.html" width="200px" height="200px"></iframe>  
Target to a link:
  1. <iframe src="http://www.javatpoint.com" name="iframe_a"></iframe>  

HTML5 Interview Questions

Let's see a list of top HTML5 interview questions and answers.

20) What is canvas in HTML5?

Canvas is an HTML area which is used to draw graphics. More details...

21) What is SVG?

HTML SVG is used to describe the two dimensional vector and vector/raster graphics. More details...

22) What are the different new form element types in HTML 5?

Following is a list of 10 important new elements in HTML 5:
  • Color
  • Date
  • Datetime-local
  • Email
  • Time
  • Url
  • Range
  • Telephone
  • Number
  • Search

23) Is there any need to change the web browsers to support HTML5?

No. Almost all browsers (updated versions) support HTML 5. For example: Chrome, Firefox, Opera, Safari, IE etc.

24) Which video formats are supported by HTML5?

HTML 5 supports three types of video format:
  • mp4
  • webm
  • ogg

25) Is audio tag supported in HTML 5?

Yes. It is used to add sound or music files on the web page. 

26) What is the difference between progress and meter tag?

The progress tag is used to represent the progress of the task only while the meter tag is used to measure data within a given range.

27) What is the use of figure tag in HTML 5?

The figure tag is used to add a photo in the document on the web page. More details...

28) What is button tag?

The button tag is used in HTML 5. It is used to create a clickable button within HTML form on the web page. It is generally used to create a "submit" or "reset" button. More details...

29) What does details and summary tag?

The details tag is used to specify some additional details on the web page. It can be viewed or hidden on demand. The summary tag is used with details tag. More details...

30) What is datalist tag?

The HTML 5 datalist tag provides an auto complete feature on form element. It facilitates users to choose the predefined options.

31) How tags are migrated from HTML4 to HTML5?

No.Typical HTML4Typical HTML5
1)<div id="header"><header>
2)<div id="menu"><nav>
3)<div id="content"><section>
4)<div id="post"><article>
5)<div id="footer"><footer>

Header and Footer Example

HTML 4 Header and Footer:
  1. <div id="header">  
  2.   <h1>Monday Times</h1>  
  3. </div>  
  4. .  
  5. .  
  6. .  
  7. <div id="footer">  
  8.   <p>&copy; niit student. All rights reserved.</p>  
  9. </div>  
HTML 5 Header and Footer:
  1. <header>  
  2.   <h1>Monday Times</h1>  
  3. </header>  
  4. .  
  5. .  
  6. .  
  7. <footer>  
  8.   <p>© niitstudy. All rights reserved.</p>  
  9. </footer>  

Menu Example

HTML 4 Menu:
  1. <div id="menu">  
  2.   <ul>  
  3.     <li>News</li>  
  4.     <li>Sports</li>  
  5.     <li>Weather</li>  
  6.   </ul>  
  7. </div>  
HTML 5 Menu:
  1. <nav>  
  2.   <ul>  
  3.     <li>News</li>  
  4.     <li>Sports</li>  
  5.     <li>Weather</li>  
  6.   </ul>  
  7. </nav>  

32) If I do not put <!DOCTYPE html> will HTML 5 work?

No, browser will not be able to identify that it is a HTML document and HTML 5 tags will not function properly.

33) What is the use of required attribute in HTML5?

It forces user to fill text on textfield or textarea before submitting form. It is used for form validation.
Example:
  1. Name: <input type="text" name="name" required>  

34) What are the new <input> types for form validation in HTML5?

The new input types for form validation are email, url, number, tel and date.
Example:
  1. <input type="email"> 

Friday, December 16, 2016

Create a Simple Java Web Application Using Servlet, JSP and JDBC

Create a Simple Java Web Application Using Servlet, JSP and JDBC

Brower         web app                         servlet
    
request >----------------------------------- insert,update,
 response<----------------------------------- delete,select.......
                                                               ..query
                                                                     |
                                                                     |   forward
                                                                     |
                                                                    jsp page show 

Frist You create a table in oracle ,mysql,Sql sver

create table USER_ACCOUNT
(
USER_NAME VARCHAR2(30) not null primary key,
GENDER    VARCHAR2(1) not null,
PASSWORD  VARCHAR2(30) not null
);


create table PRODUCT

(
CODE  VARCHAR2(20) not null primary key,
NAME  VARCHAR2(128) not null,
PRICE FLOAT not null
) ;





insert into user_account (USER_NAME, GENDER, PASSWORD)

values ('prabal', 'M', 'niit@123');
insert into user_account (USER_NAME, GENDER, PASSWORD)
values ('akash', 'M', 'niit@123');


insert into user_account (USER_NAME, GENDER, PASSWORD)
values ('maneesha', 'F', 'niit@1234');
insert into product (CODE, NAME, PRICE)
values ('P001', 'Java Core', 100);
insert into product (CODE, NAME, PRICE)
values ('P002', 'C program', 90);


insert into product (CODE, NAME, PRICE)

values ('P003', 'Devops', 9000);

Then Go to Eclipse and open Dynamic project
And add index.html


 then write a index.html
<html>
  <head>
     <meta charset="UTF-8">
     <title>Simple Web Application</title>
  </head>
  
  <body>
  
  
      
     <ul>
        <li><a href="home">Home</a></li>
        <li><a href="login">Login</a></li>
        <li><a href="productList">Product  List</a>
     </ul>
      
  </body>
</html>


Copy these libraries (
)into the WEB-INF/lib:

and add javax.servlet.jsp.jstl and javax.servlet.jsp.jstl-api and add
  • http://mvnrepository.com/artifact/org.glassfish.web/javax.servlet.jsp.jstl
then go to to src and add package name
and add java class
Class name USERACCOUNT
package com.simplewebapp.beans;
public class UserAccount {
   public static final String GENDER_MALE ="M";
   public static final String GENDER_FEMALE = "F";
    
   private String userName;
   private String gender;
   private String password;
    
   public UserAccount() {
        
   }
    
   public String getUserName() {
       return userName;
   }
   public void setUserName(String userName) {
       this.userName = userName;
   }
   public String getGender() {
       return gender;
   }
   public void setGender(String gender) {
       this.gender = gender;
   }
   public String getPassword() {
       return password;
   }
   public void setPassword(String password) {
       this.password = password;
   }
} 


AND ADD CLASS  Product

package com.simplewebapp.beans;
public class Product {
   private String code;
   private String name;
   private float price;
   public Product() {
   }
   public Product(String code, String name, float price) {
       this.code = code;
       this.name = name;
       this.price = price;
   }
   public String getCode() {
       return code;
   }
   public void setCode(String code) {
       this.code = code;
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
   public float getPrice() {
       return price;
   }
   public void setPrice(float price) {
       this.price = price;
   }
}

then create a package For connection

and add class for oracle

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class OracleConnUtils {
  public static Connection getOracleConnection()
          throws ClassNotFoundException, SQLException {
      
      // Note: Change the connection parameters accordingly.
      String hostName = "localhost";
      String sid = "db11g";
      String userName = "system";
      String password = "oracle";
      return getOracleConnection(hostName, sid, userName, password);
  }
  public static Connection getOracleConnection(String hostName, String sid,
          String userName, String password) throws ClassNotFoundException,
          SQLException {
           
      Class.forName("oracle.jdbc.driver.OracleDriver");
      // URL Connection for Oracle
      // Example: jdbc:oracle:thin:@localhost:1521:db11g
      String connectionURL = "jdbc:oracle:thin:@" + hostName + ":1521:" + sid;
      Connection conn = DriverManager.getConnection(connectionURL, userName,
              password);
      return conn;
  }
}


Add a class ConnectionUtils


import java.sql.Connection;
import java.sql.SQLException;
public class ConnectionUtils {
   public static Connection getConnection()
             throws ClassNotFoundException, SQLException {
      
       // Here I using Oracle Database.
       return OracleConnUtils.getOracleConnection();
     }
    
   public static void closeQuietly(Connection conn) {
       try {
           conn.close();
       } catch (Exception e) {
       }
   }
   public static void rollbackQuietly(Connection conn) {
       try {
           conn.rollback();
       } catch (Exception e) {
       }
   }

}