Tuesday, February 14, 2017

Struts Interview Questions and answers

In this post we will learn frequently asked Struts Interview Questions.As a senior developer,must have strong knowledge on Struts Framework. This is one of the Core Framework to develop web application efficient and effective manner.

1) What is Struts?


Ans: Struts is a open source framework used to develop Java based web page.Struts takes the help of Model View Controller(MVC) architecture. Here framework means"It is a reusable, "semi-complete"application that can be specialized to produce custom applications.


2) What is the need of Struts?


Ans: We need Struts in Java because of following reasons:



  1. It helps in creation and maintenance of the application
  2. Make use of Model View Controller(MVC) architecture. Where model is referring to business or database.View is referring to the page Design code and Controller is referring to navigational code
  3. Struts combines Java Servlets, Java ServerPages, custom tags, and message resources into a unified framework. The end result is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone in between.
3) What is the difference between Model2 and MVC models?

Ans: In model2, we have client tier as jsp, controller is servlet, and business logic is java bean. Controller and business logic beans are tightly coupled. And controller receives the UI tier parameters. But in MVC, Controller and business logic are loosely coupled and controller has nothing to do with the project/ business logic as such. Client tier parameters are automatically transmitted to the business logic bean, commonly called as ActionForm.

So Model2 is a project specific model and MVC is project independent

4) What is MVC?


Ans: Model View Controller(MVC) is a design pattern used to perform changes in the application. For more details about MVC click on the following link: MVC Architecture


5) What is Action Class?

Ans: The Action Class is part of the Model and is a wrapper around the business logic. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class all the database/business processing are done. It is advisable to perform all the database related stuffs in the Action Class. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

Example:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class BillingAdviceAction extends Action 
{
 public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception 
{
BillingAdviceVO bavo = new BillingAdviceVO();
BillingAdviceForm  baform = (BillingAdviceForm)form;
DAOFactory factory = new MySqlDAOFactory();
BillingAdviceDAO badao = new MySqlBillingAdviceDAO();    
ArrayList projects = badao.getProjects();
request.setAttribute("projects",projects);
return (mapping.findForward("success"));
}
}

6) What is Action Form?

Ans: An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side

Example:


public class BillingAdviceForm extends ActionForm 
{
private String projectid;
private String projectname;   
 public String getProjectid() 
 return projectid;  
}
public void setProjectid(String projectid) 
{  
this.projectid = projectid;  
}    
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
{
ActionErrors errors = new ActionErrors();
if(getProjectName() == null || getProjectName().length() < 1)
{
errors.add(“name”, new ActionError(“error.name.required”));
}         
return errors;
}
public void reset(ActionMapping mapping, HttpServletRequest request)
{
this.roledesc = "";
this.currid      = "";
}
}

7)How to Configure Struts?


Ans: Before being able to use Struts, you must set up your JSP container so that it knows to map all appropriate requests with a certain file extension to the Struts action servlet. This is done in the web.xml file that is read when the JSP container starts. When the control is initialized, it reads a configuration file (struts-config.xml) that specifies action mappings for the application while it's possible to define multiple controllers in the web.xml file, one for each application should suffice

8) What is validate() and reset() methods? Explain?

Ans: 

Validate() method: It is used to validate the properties after they are explored by the application. validate method is called before FormBean is handled to Action. This method returns a collection of ActionError.

Syntax:
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)

reset(): This method is called by the Struts Framework with each request that uses the defined ActionForm. The main purpose of this method is to reset all the data from the ActionForm

Syntax:
public void reset()
{}



9)How struts validation is working?
Ans: Validator uses the XML file to pickup the validation rules to be applied to a form. In XML validation requirements are defined applied to a form. In case we need special validation rules not provided by the validator framework, we can plug in our own custom validations into Validator.

The Validator Framework uses two XML configuration files validator-rules.xml & validation.xml. The validator-rules.xml defines the standard validation routines; such as Required, Minimum Length, Maximum length, Date Validation, Email Address validation and more. These are reusable and used in validation.xml. To define the form specific validations. The validation.xml defines the validations applied to a form bean.

10)What is Tiles?
Ans:  Tiles is a framework for the development user interface, Tiles is enables the developers to develop the web applications by assembling the reusable tiles.
1. Add the Tiles Tag Library Descriptor (TLD) file to the web.xml. 
2. Create layout JSPs. 
3. Develop the web pages using layouts. 


11)How you will handle errors & exceptions using Struts?
Ans: 
  • To handle "errors" server side validation can be used using ActionErrors classes can be used. 
  • The "exceptions" can be wrapped across different layers to show a user showable exception. 
  • Using validators
12)How you will save the data across different pages for a particular client request using Struts?

Ans: If the request has a Form object, the data may be passed on through the Form object across pages. Or within the Action class, call request.getSession and use session.setAttribute(), though that will persist through the life of the session until altered.
(Or) Create an appropriate instance of ActionForm that is form bean and store that form bean in session scope. So that it is available to all the pages that for a part of the request

13)What is the difference between ActionForm and DynaActionForm?

Ans:
 1. In struts 1.0, action form is used to populate the html tags in jsp using struts custom tag.when the java code changes, the change in action class is needed. To avoid the chages in struts 1.1 dyna action form is introduced.This can be used to develop using xml. The dyna action form bloats up with the struts-config.xml based definetion.
2. There is no need to write actionform class for the DynaActionForm and all the variables related to the actionform class will be specified in the struts-config.xml. Where as we have to create Actionform class with getter and setter methods which are to be populated from the form
3.if the formbean is a subclass of ActionForm, we can provide reset(),validate(),setters(to hold the values),gettters whereas if the formbean is a subclass to DynaActionForm we need not provide setters, getters but in struts-config.xml we have to configure the properties in using .basically this simplifies coding

DynaActionForm which allows you to configure the bean in the struts-config.xml file. We are going to use a subclass of DynaActionForm called a DynaValidatorForm which provides greater functionality when used with the validation framework.

<struts-config>
    <form-beans>
        <form-bean name="employeeForm" type="org.apache.struts.validator.DynaValidatorForm">
            <form-property name="name" type="java.lang.String"/>
            <form-property name="age" type="java.lang.String"/>
            <form-property name="department" type="java.lang.String" initial="2" />
            <form-property name="flavorIDs" type="java.lang.String[]"/>
            <form-property name="methodToCall" type="java.lang.String"/>
        </form-bean>
    </form-beans>
</struts-config>

This DynaValidatorForm is used just like a normal ActionForm when it comes to how we define its use in our action mappings. The only 'tricky' thing is that standard getter and setters are not made since the DynaActionForms are backed by a HashMap. In order to get fields out of the DynaActionForm you would do: 

String age = (String)formBean.get("age"); 
Similarly, if you need to define a property: 
formBean.set("age","30");

14)Can you write your own methods in Action class other than execute() and call the user method directly?
Ans:Yes, we can create any number of methods in Action class and instruct the action tag in struts-config.xml file to call that user methods.

Public class StudentAction extends DispatchAction
{
      public ActionForward read(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception 
      { 
Return some thing;
      }
public ActionForward update(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exceptio 
      { 
Return some thing;
      }
If the user want to call any methods, he would do something in struts-config.xml file.
<action path="/somepage" 
      type="com.odccom.struts.action.StudentAction"
      name="StudentForm"
      <b>parameter=”methodToCall”</b>
      scope="request"
      validate="true">
<forward name="success" path="/Home.jsp" />
</action>

15)Can I have more than one struts-config.xml?
A) Yes you can I have more than one.
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
 <param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<! — module configurations -- > 
<init-param>
<param-name>config/exercise</param-name>
<param-value>/WEB-INF/exercise/struts-config.xml</param-value>
 </init-param>
  </servlet>

Monday, February 13, 2017

How to find duplicate elements in Array In Java

In this post I am sharing how to detect duplicate values in array using Java Programming. This is one the frequently asked programming interview question in technical interview. I am showing two methods to find duplicate elements in array. Interviewer wants to know your logical thinking how could solve  problems easy way. So, be ready to write programming logic's in efficient and effective manner.

The following are the steps how to detect duplicate values in array:


  • First you need to create and initialize input array
  • Create an empty set and name it as non duplicate set
  • create an empty set and name it as duplicate set
  • Now iterate through each element in the array and check whether non-duplicates contains the element. If it is present add it to the duplicate set
  • If it is not present add it to non duplicate set
  • Finally Print the elements in duplicate set
Method 1:

Now let us see the program to find print duplicate elements in the array

import java.util.HashSet;
import java.util.Set;
class DuplicateElementsArray
{
public static void main(String args[])
{
String duplicate[]=new String[]{"apple","grapes","banana","apple"};
Set nonDuplicatesSet=new HashSet();
Set duplicateSet=new HashSet();
for(String s:duplicate)
{
if(!nonDuplicatesSet.contains(s))
{
nonDuplicatesSet.add(s);
}
else
{
duplicateSet.add(s);
}
}
System.out.println(duplicateSet);
}

Output:


Method 2:


import java.util.HashSet;
import java.util.Set;

class DuplicateValuesInArray
{
public static void main(String args[]){
int[] arr={2,3,4,1,1,5,3};

Set<Integer>set=new HashSet<Integer>();
for(int i=0;i<arr.length;i++)
{
if(set.add(arr[i])==false)
{
System.out.println("Duplicate values:"+arr[i]);
}


Output:

Wednesday, February 8, 2017

Basic Hadoop Interview Questions

In this page i am sharing Hadoop Interview Questions which are frequently asked in Technical Round for Hadoop Developers.Earlier i was written for Hadoop developers who want start learning Hadoop prerequisite for learning Hadoop

1) What is Hadoop?

Ans:  Hadoop is a framework that allows for distributed processing of large data sets across clusters of commodity computers using a simple programming model.

2) Why the name Hadoop?

Ans: Hadoop doesn't have any expanding version like oops. The charming yellow elephant you see is basically named after Dougs sons toy elephant.

3) Why do we need Hadoop?

Ans: Everyday a large amount of unstructured data is getting dumped into our machines. The major challenge is not to store large data sets in our systems but to retrieve and analyze the big data in the organizations,that too data present in different machines at different locations. In this situation a necessary for Hadoop arises. Hadoop has the ability to analyze the data present in different machines at different way. It uses the concept of MapReduce which enables it to divide the query into small parts and process them in parallel. This is also known as parallel computing.

4) Give some examples of some companies that are using Hadoop Structure?

Ans: A lot companies are using the Hadoop Structure such as  Facebook,eBay,Amazon,
Twitter, Google and so on...

5) What is the basic Difference between RDBMS and Hadoop?

Ans: A Traditional RDBMS is used for transnational systems to report and archive the data,whereas Hadoop is an approach to store huge amount of data in the distributed file system and process it. RDBMS will be useful when you want to seek one record from Big data,whereas Hadoop will be useful when you want Big data is one shot and perform analysis on that later.

6) What is Structured and unstructured data?

Ans: Structured data is the data that is easily identifiable form as it organized in a structure. The most common form of structured data is a database where specific information is stored in tables,that is rows and columns. Unstructured data refers to any data that can not be identified easily. It could be in the form of images,videos,documents,email,logs and random text. It is not in the form of rows and columns.

7) What are the core componenets of Hadoop?

Ans: Core components of Hadoop are HDFS and MapReduce. HDFS is basically used to store large data sets and MapReduce is used to process such large data sets. 

8) What is HDFS?

Ans: HDFS is a file system designed for storing very large files with streaming data access patterns,running clusters on commodity hardware.


9) What is Fault Tolerance?

Ans: Suppose you have a file stored in a system,and due to some technical problem that file gets destroyed. Then there is no chance of getting data back present in that file. To avoid such situations ,Hadoop has introduced the feature of Fault Tolerance in HDFS. In Hadoop, where we store a file,it automatically gets replicated at two other locations also. So even if one or two of the systems collapse,the file still on the third system.

10)  What is meaning Replication factor?

Ans: Replication Factor defines the number of times a given data block is stored in the cluster. The default replication factor is 3. This also means that you need to have 3 times the amount of storage needed to store the data. Each file is split into data blocks and spread across cluster.


11) What is MapReduce?

Ans: MapReduce is a set of programs used to acess and manipulate large data sets over a Hadoop cluster.

12) What is the InputSplit in map reduce software?

Ans: An InputSplit is the slice of data to be processed by a single Mapper. It generally is of the block size which is stored on the database.

13) How does master slave architecture in the Hadoop?

Ans: Totally 5 daemons run in Hadoop Master-slave architecture. On Master Node: Name node and job Tracker and Secondary name Node on Slave: Data Node and Task Tracker But it is recommended to run secondary name node in a separate machine which have Master node capacity.

14) What is the Reducer used for?

Ans: Reducer is used to combine the multiple outputs of mapper to one.

15) What are the primary phases of the Reducer?

Ans: A Reducer has 3 primary phsases they are 1) Shuffle 2) sort 3) reduce

16) What is the typical block size of an HDFS block?


Ans: Default block size is 64mb but 128mb is typical .

17) How input and output data format of the Hadoop Framework?

Ans: There are different data format such as Fileinputformat,textinputformat,keyvaluetextinputformat,wholefileformat are file formats in hadoop framework.

18) Can I set the number of reducers to zero?

Ans: Yes. It can be set as zero. So, the mapper output is an finalized output and stores in HDFS.

19) What are the Map files and why are they important in Hadoop?

Ans: Map files are sorted sequence files that also have an index. The index allows fast data look up.

20) How can you use binary data in MapReduce in Hadoop?

Ans: Binary data can be used directly by a map-reduce job.Often binary data is added to a sequence file.




Java 8 Stream API

In this article we will understand and learn about Stream API in Java 8 Version. This is one of core concept in Core Java. Java 8 brings new abilities to work with Collections,in the form of a brand new Stream API. This new functionality is provided by the java.util.stream package. 

The Stream API offers easy filtering,counting and mapping of Collections as well as different ways to get slices and subsets of information out of them. The Stream API allows shorter and more elegant code for working with collections.

Stream represents a sequence of objects. A stream operates on data source,such as an array or Collections. A stream never provides storage for the data. It simply moves the data,possibly filtering,sorting on that data in the process.

The Stream API defines several stream interfaces, which are packaged in java.util.stream

BaseStream is a generic interface declared like this:

interface BaseStream<T, S extends BaseStream<T,S>>

In the above T specifies the type of elements in the stream, and S represents the type of stream that extends BaseStream. BaseStream extends AutoCloseable interface,thus a stream can be managed in try-with-resources statement.

How to obtain a Stream:

You can obtain a stream in a number of ways. Perhaps the most common is when a stream is obtained for a collection. In JDK 8, the Collection interface has been expanded to include two methods that obtain a stream from a collection. The first is stream() as shown below

default Stream<E>stream()

The second method is

 default Stream<E>parallelStream()

A stream can be obtained from an array by use of the static stream() method,which was added to the arrays class by JDK 8. 

static <T> Stream<T> stream(T[ ] array)

This method returns a sequential stream to the elements in array. For example, given an
array called addresses of type Address, the following obtains a stream to it:
 

Stream<Address> addrStrm = Arrays.stream(addresses); 

Lets start with a short example. We will use this data model in all examples:

Class Author{
String name;

int countOfBooks;
}
class Book{
String name;
int year;
Author author;
}
Let's imagine that we need to print all authors in a books collection who wrote a book after 2010. How would we do it in Java 7?

for(Book book:books){
if(book.author!=null&&book.year>2010)
{
System.out.println(book.author.name);
}
}

In Java 8 how would we do that same problem above:

books.stream().filter(book ->book.year>2010)
//filter out books published in or before 2010

.map(Book::getAuthor)//get the list of authors from the list

.map(Author::getName//get the list of names for remaining authors 

.forEach(System.out::println)//print the value of each remaining element

It is only one expression that is the method stream() on any Collection returns a Stream object encapsulating all the elements of that collection. This can be manipulated with different modifiers from the Stream API, such as filter() and map(). Each modifier returns a new Stream Object  with the results of the modification,which can be further manipulated. The forEach() method allows us to perform some action for each instance of the resulting stream.

The Stream API helps developers look at java collections from a new angle. Imagine now that we need to get a Map of available languages in each country. How would this be implemented in Java 7?

Map<String, Set<String>>CountryToSetOfLanguages=new HashMap<>();

for(Locale locale:Locale.getAvailableLocales())
{
String country=locale.getDisplayCountry();

if(!countryToSetOfLanguages.containsKey(country))
{
countryToSetOfLanguages.put(country,new HashSet<>());
}
countryToSetOfLanguages.get(country).add(locale.getDisplayLanguage());
}

In java 8 the above same will be rewritten below:

import java.util.stream.*;
import static java.util.stream.Collectors.*;
.........
........
Map<String, Set<String>>CountryToSetOfLanguages=Stream.of(Locale.getAvailableLocales()).collect(groupingBy(Locale::getDisplayCountry,mapping(
Locale::getDisplayLanguage,toSet())));

The method collect() allows us to collect the results of a stream in different ways. Here,we can see that it firstly groups by country,and then maps each group by language(groupinBy() and toSet() are both static methods from the Collectors class).




 

Tuesday, February 7, 2017

JSP Interview Questions and Answers

In this page we will learn frequently asked interview questions for freshers and experienced developers. JSP is a server side technology,it can be used to prepare presentation/view part in the web application development. JSP pages can be deploy at any place in the web application directory structure. Now let us see frequently asking questions .

1) What is JSP?

Ans: JSP stands for Java Server Page,It is a server side technology and it is used to prepare presentation/view part in the web application development.The main purpose of JSP is for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags,most of which start with<% and end with %>.

2) What are advantages of using JSP?

Ans: JSP offer several advantages listed below:

  1. JSP is always compiled before it's processed by the server unlike.
  2. Performance is significantly better because JSP allows embedding Dynamic Elements in HTML pages itself.
  3. Java server pages are built on top of the Java Servlets API,so like Servlets,JSP also has access to all the powerful enterprise JAVA APIs including JDBC,JNDI,EJB,JAXP etc.
  4. JSP pages can be used in combination with servlets that handle the business logic,the model supported by Java servlet template engines.
3) Difference Between JSP & Servlets?
Ans:  
  • In JSP we can easily separate the presentation Logic with Business Logic but in servlets both are combined
  • One servlet object is communicated with many number of objects,but jsp it is not possible.
  • Internally when JSP is executed by the server it converted into servlet . Therefore we can say that JSP & servlets are work almost similar.
4) What are the web application scope?

Ans: There are 3 web application scopes. They are
1) Request
2)session
3)Application

5) What is JSP declarations?

Ans: A declaration declares one or more variables or methods that you can use in Java code later in JSP file. You must declare the variable or method before you use it in the JSP file
<%declaration; [declaration;]....%>

6) What are JSP expressions?

Ans: A JSP expression element contains a scripting language expression that is evaluated,converted to a string,and inserted where the expression appears in the JSP file. The expression element can contain any expression that is valid according to the java language specification but you can not use a semicolon to end an expression.

Syntax: <%=expression%>

7) What are JSP directives?

Ans: A JSP directive affects the overall structure of the servlet class. It usually has the following form: <%@ directive attribute="value" %>

8) What are the JSP actions?

Ans:  JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file,reuse Java Beans components,forward the user to another page,or generate HTML for the Java plugin.

Syntax: <JSP: action_name   attribute="value">

9) Give some of the JSP action names?

Ans:  There are some frequently used jsp actions. They are

jsp:include
jsp:forward
jsp:useBean
jsp:body
jsp:attribute


10) What is page directive?

Ans: 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.

11)what are Difference between <%@ include file="file" %> & <jsp:include page=”abc.jsp” %> ?

Ans: 
<%@include file="abc.jsp"%> directive acts like C "#include", pulling in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text). (Or) includes a jsp/servlet at compile time meaning only once parsed by the compiler.
<jsp:include page="abc.jsp"> include a jsp/servlet at request time it is not parsed by the compiler.

12)What are Difference between res.sendRedirect( ) & req.forward( ) ?

Ans: 

sendRedirect() : It sends a redirect response back to the client's browser. The browser will normally interpret this response by initiating a new request to the redirect URL given in the response. 
forward(): It does not involve the client's browser. It just takes browser's current request, and hands it off to another servlet/jsp to handle. The client doesn't know that they're request is being handled by a different servlet/jsp than they originally called. 
Example: if you want to hide the fact that you're handling the browser request with multiple servlets/jsp, and all of the servlets/jsp are in the same web application, use forward() or include(). If you want the browser to initiate a new request to a different servlet/jsp, or if the servlet/jsp you want to forward to is not in the same web application, use sendRedirect (). 

13) How does JSP handle runtime exceptions?

Ans: 
You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. 
For example:
<%@ page errorPage=\"error.jsp\" %> 
redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive: <%@ page isErrorPage=\"true\" %>.

14)How do I prevent the output of my JSP or Servlet pages from being cached by the Web browser? And Proxy server?

Ans:
Web browser caching:
<% response.setHeader("Cache-Control","no-store"); 
   response.setHeader("Pragma","no-cache"); 
   response.setDateHeader ("Expires", 0); 
 %>
   
Proxy server caching:
response.setHeader("Cache-Control","private");

15)What's a better approach for enabling thread-safe servlets & JSPs? SingleThreadModel Interface or Synchronization?

Ans:
SingleThreadModel technique is easy to use, and works well for low volume sites. If your users to increase in the future, you may be better off implementing explicit synchronization for your shared data Also, note that SingleThreadModel is pretty resource intensive from the server's perspective. The most serious issue however is when the number of concurrent requests exhaust the servlet instance pool. In that case, all the unserviced requests are queued until something becomes free.

16) What are the various attributes of page directive?

Ans: The following are the page attributes:

  • language
  • extends
  • import
  • session
  • isThreadSafe
  • errorPage
  • contentType
  • autoFlush
17) What is include directive?

Ans: The include directive is used to includes a file during the translation phase. This directive tells the container to merge the content of other external files with the current JSP during the translation phase. 

Syntax: <%@ include file="relative url">

18) What is taglib directive?

Ans: The tablib directive follows the following 

Syntax: <%@ tablib uri="uri" prefix="prefixOfTag">

In the above uri attribute value resolves to a location the container understands.
prefix attribute informs a container what bits of markup are custom actions.

19)What implicit objects are supported by JSP?

Ans: request,response,out,session,application,exception

20) What are difference between JspWriter and PrintWriter?

Ans:  The JspWriter object contains most of the same methods as the java.io.PrintWriter class. However,JspWriter has some additional methods designed to deal with buffering. Unlike the PrintWriter object,JspWriter throws IOExceptions.

21) What is session Object?

Ans: The session object is an instance of javax.servlet.http.HttpSession and is used to track client session between client requests.

22) What are difference between GET and POST method in HTTP protocol?

Ans: 
The GET method sends the encoded user information appended to the page request.The page and the encoded information are separated by the ? character.

The  POST method packages the information in exactly the same way as GET methods,but instead of sending it as text string after a ? in the URL it sends it as a separate message. This message comes to the backend program in the form of the standard input which you can parse and use for your processing.

23) How to read data form data using JSP?

Ans: By using getParameter(),getParameterValues(),getParameterName(),getInputStream()

getParameter(): You can call request.getParameter() method to get the value of a form parameter.

getParameterValues(): Use this method to call if the parameter appears more than once and returns multiple values. Example: Checkbox

getParameterName(): This method is used if you want a complete list of all parameters in the current request.

24) Define Filters?

Ans: JSP Filters are java classes that can be used in JSP programming for the following purpose:
  • To manipulate responses from server before they are sent back to the client
  • To intercept requests from a client before they access a resource at back end.
25)  What are cookies?

Ans: Cookies are text files stored on the client computer and they are kept for various information tracking purpose.

26)How do set Cookies in the JSP page?

Ans:  There are three steps to set cookies in JSP

Creating a cookie object
Setting the maximum age
Sending the Cookie into the HTTP response Headers

27) What is auto refresh feature in JSP?

Ans: Consider a webpage which is displaying live game score or stock market status or currency exchange ration. For all such types of pages,you would need to refresh your web page regularly using refresh or reload button with your browser.

Here jsp makes this job easy by providing you a mechanism where you can make a webpage in such a way that it would refresh automatically after a given interval.

Example:  response.setIntHeader("Refresh","5 ; URL=http://www.cricbuzz.com")

28) What is JSTL?

Ans: The Java Server Pages Standard Tag Library(JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications. It supports for common,structural tasks such as iteration and conditionals,tags for manipulating XML documents and SQL tags.

29) How do you pass control from one JSP page to another?

Ans:

The following are the ways to pass control of a request from one servlet to another or one jsp to another: They are

  • Using the response.sendRedirect() method
  • Using RequestDispatcher object's forward method to the pass the control
30) What are the difference between Java Beans and taglib directives?

Ans:
Java Beans and taglib fundamentals were introduced for reusability. The following are the major differences:
  1. Taglibs are for generating presentation elements while Java Beans are good for storing information and state
  2. Use custom tags to implement actions and Java Beans to present information





Monday, February 6, 2017

Fundamental Networking Interview Questions

In this post i am sharing Basic Networking Interview Questions for all Project Developers. The Basic Networking Knowledge is required for all software Developers. The following are the few of the Basic networking Interview Questions.

1) What is Network?

Ans: A network is a set of devices connected by physical media links. It is used to share resources such as  data, printers,CD-ROM and exchanging files. The main purpose of the networking is to share information.

2) What is Node?

Ans: A network can consists of two or more computers directly connected by some physical medium such as coaxial cable or optical fiber. Such a physical medium is called as Links and computer it connects is called as Nodes.

3) What is Protocol?

Ans: A Protocol is a set of rules that govern all aspects of information communication.

4) Define Routing?

Ans: The process of determining systematically Hoe to forward messages toward the destination nodes based on its address is called routing?

5) What is gateway?

Ans: A node that is connected two or more networks is commonly called gateway. It generally forwards message from one network to another.

6)  What is difference between Gateway and Router?

Ans:  The Gateway operates at the upper levels of the OSI model and translates information between two completely different network architecture or data formats.

7) What is Bandwidth?



Ans: Every line has an upper limit and a lower limit on the frequency of signals it can carry.This limited range is called the bandwidth.

8) What is MAC address?

Ans: The address for a device as it is identified at the Media Access Control(MAC) layer in the network architecture. MAC address is usually stored in ROM on the network adapter card and is unique.

9) What is SMTP?

Ans: SMTP stands for Simple Mail Transfer Protocol. It is used to exchanges mail between servers.


10) Define Proxy Server?

Ans: A proxy Server speaks the client side of a protocol to another server. This is often required when clients have certain restrictions on which servers they can connect to. When several users are hitting a popular website, a proxy server can get the contents of the web server's popular pages once,saving expensive inter network transfers while providing faster access to those pages to the clients. Also,we can get multiple connections for a single server.

11) What is difference between TCP and UDP?

Ans: These two protocols differ in the way they carry out the action of communicating. A TCP protocol establishes a two way connection between a pair of computers whereas the UDP protocol is one way message sender. The common analogy is that TCP is like making a phone call and carrying on a two-way communication,while UDP is like mailing a letter.

12) What are the seven layers of OSI model?

Ans:

  1. Application Layer
  2. Presentation Layer
  3. Session Layer
  4. Transport Layer
  5. Network Layer
  6. DataLink Layer
  7. Physical Layer
13)What is DHCP?

Ans: DHCP stands for Dynamic Host Configuration Protocol,a piece of the TCP/IP protocol suite that handles the automatic assignment of IP address to clients.

14) Is it possible to get the Local host IP?

Ans: YES. By using InetAddress getLocolHost method.

15)What is peet-peer process?

Ans: The process on each machine that communicate at a given layer are called peer-peer process.

16) What is Checksum?

Ans: Checksum is used by the higher layer protocol(TCP/IP) for error detection.
17) What is subnet?

Ans: A generic term for section of a large networks usually separated by a bridge or router.

18) Define Encoder?

Ans: A device or program that uses predefined algorithms to encode,or compress audio or video data for storage or transmission use. It is a process to convert between digital audio and analog video.

19) Define Decoder?

Ans: A device or program that translates encoded data into its original format. The term is often used in reference to MPEG-2 video and sound data,which must be decoded before it is output.

20) What is RAID?

Ans:  It is a method for providing fault tolerance by using multiple hard disk drives.

Watch Video : Basic Networking Interview Questions for freshers

High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...