Your Ad Here

Wednesday, December 31, 2008

JSP Interview Questions & Answers

Q : What is a JSP and what is it used for?
A : Java Server Pages is a platform independent presentation layer technology that comes with SUN s J2EE platform. JSPs are normal HTML pages are with Java code pieces embedded in them. JSP pages are saved to *.jsp files. A JSP compiler is used to in the background to generate a Servlet from the JSP page.

Q : What is JSP technology?
A : Java Server Page is a standard Java extension that is defined on top of the servlet Extensions. The goal of JSP is the simplified creation and management of dynamic Web pages. JSPs are secure, platform-independent, and the best of all, make use of Java as a server-side scripting language.

Q : How many JSP scripting elements ?
A : There are three JSP scripting language elements:
• Scriptlets
• Declarations
• Expressions

Q : What is the information needed to create a TCP Socket?

A : The Remote System’s IPAddress and Port Number.
The Local Systems IP Address and Port Number.

Q : What is difference between JSP 1.0 model and JSP 2.0 model?

A : The main difference between the JSP 1.0 and JSP 2.0 has feature in that by which we can create more syntax errors due to TLD.

Q :Diffrence betweeen a statis and dynamic include?

Dynamic include means files are included at run time.
If there is any change in source file it will reflected in JSP
Static include means files are included at compile time. After inclusion if there any change in source file it will not reflect that JSP.

Q : What’s the differences between JSP LifeCycle and Servlet LifeCycle?
A : In servlet we can implement init, service and destroy method but in JSP we do not have any implementation for that i.e JSP container is taking care of that implementation . Finally only translation phase is different i.e JSP converted into servlet.

Q : What is the difference between web server and application server?
A : Application server is EJB. It can communicate will both Web and Distributed Architecture. Application server is a Component Architecture
Web server can not communicate with Component Architecture or Distributed Architecture. It consists of Servlets and JSP pages.

Q : How to Upload a textfile from JSP to Servlet ?
A . You must use this tag for Remember form tag must contain the following attribute

Enctype ="multipart/form-data" then only it will validate file upload.

Q : What’s the difference between JSP forward and servlet forward methods?

A : JSP forward forwards the control to another resource available in the same web application on the same container. where as a Servlet forward forwards the control to another resource available in the same web application or different web application on the same container.

Q : How to call EJB from JSP.?
We need to write a JavaBean which implements the code for the EJB client. This is JavaBean can interact with the JSP using useBean JSP action.

Q : What is the difference between jsp include and directive include?
A : <%@ include> : Used to include dynamic content or static content during runtime
Used to include static resources during translation time. :

Q : How does JSP handle runtime exceptions?
A: Using the error Page attribute of page directive and also we need to specify the error page isErrorPage=true if the current page is intended to URL redirecting of a JSP.

Q : What are the implicit objects?
A : Implicit objects are objects that are created by the web container and contain the information related to a particular request, page, or application. They are:
• Request
• session
• response
• pageContext
• application
• out
• exception
• config
• page

Q : What is an Expression?

A : An expression is a tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. Because the value of an expression is converted to a String, you can use an expression within text in a JSP file. Like
<%= someexpression %>
<%= (new java.util.Date()).toLocaleString() %> You won’t use the semicolon to end an expression.

0 comments:

Your Ad Here