Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

JavaScript

1 What is JavaScript?
JavaScript is a scripting language, commonly used for the client side validations in Java
Server Pages & DHTML.

2 What is client side scripting and server side scripting?

Client side scripting is associated with client and it does not need any of the server related
objects such as database. Server side scripting is associated with server and uses database
objects.

3 Object Hierarchy in Java script .what is DOM(Document Object Model) -- JavaScript ?

Document Object module is a technique used in JavaScript, using which elements of the document(an
HTML page,a form within a page etc) are identified in the script.

4 How can we use regular expression for form validation. -- JavaScript?


Regular expressions provide a facility, using which we can perform pattern validations in JavaScript.
For e.g, to validate a field for number we can use the following code.

var regExp=/^\d+$/

if(regExp.test(document.form1.field1.value))
{
return true
}
else
{
return false
}
5 Event Handling in JavaScript?

Event handling such as click can be handled using a script method, such as onClick="display()", where
display() is a JavaScript method.

JSP/Servlets

1 What is the difference between JSP and servlet?

In functional wise there is no difference between JSP and serevlet. JSP is again going to
convert into Servlet at the server and executes. But the difference comes when separating the
presentation logic with the business logic. We write all the presentation logic in jsp and all the
flow and business logic in servlet.

2. What tag of JSP is equivalent to init method of HttpServlet interface?

3. What is a singleThreadModel? What is its equivalent in JSP?

1
SingleThreadModel is an interface provided by java API to ensure that only one thread
is executing the servlet's service() method at any given time.

4. What are the ways in which a java class can be instantiated from a JSP?

By using the keyword new with full path

5. Can you write methods in JSP? If yes, how?


Yes, <% method over here %>

5. What are the various scopes available for a bean used in the USEBEAN tag?
<scope = request/page/session/application>

6. What are the various ways of managing session across the application? Explain briefly.
URL rewriting - Client specific Unique token id is passed along with the URL
Hidden form fields - Unique token is embedded within HTML form
Cookies-A cookie is a small piece of textual information sent by the server to the client
stored on the client and returned by the client for all requests to the server.

7. Explain the significance of multithreading used in servlets. How do you declare global
variables in a servlet and in a JSP?

7. How do you handle runtime errors in a JSP /servlet?


Alert messages can be set by catching the exception

8. How do you accept parameters from a form submitted via GET/POST methods?
Request.getParameter()
9. Does Applet support JDBC and Servlets?
No.
10. Use of Servlet Config , Servlet Context?

ServletConfig is an interface for representing the configuration of a servlet like


initialization parameters, the name of the servlet & a servletContext object
ServletContext interface encapsulates the notion of a context for a web application

11. What are the different types of the Servlet Code(s)?

13.What is the difference between directive & action?


Directives are messages sent to the JSP container from the JSP. They are used to set
global values such as class declarations, method to be implemented etc. and do not
produce any output to the client.
Actions are tags that affect the runtime behavior of the JSP and the response sent back
to the client. They have to be provided by all containers irrespective of implementation.

13. Can a response be redirected after it is committed . If so how?

14.Purpose for URL Encoding?


Security.

2
15.How do you pass String or a file between two Servers?

16.How do you submit a form?

Document.form.submit()
17.What is the difference between dopost and doget request?
DoGet() the parameters are transmitted through URL and hence large cannot be
transmiited.
DoPost() the parameters are transmitted through request object and hence one can
transfer large amount of data. Since the transfer is through request object, security is
ensured.
18. Difference between a forward & sendRedirect?
SendRedirect() sends a redirect response to the client. The client receives the HTTP
response 302 indicating that temporarily the client is being redirected to the specified
location. forward the request to another servlet or a JSP page or an HTML file .

19 Difference between jsp:include and include directive ?


The include directive is used to include resources at runtime. The include
method is a method in RequestDispatcher interface to include the content
produced by another resource in the calling servlet's response.

20 How does the container handle multiple requests for the same Servlet?

You might also like