Professional Documents
Culture Documents
Programming
Programming
Programming
Q1. Explain the two main ways that HTTP protocol to send information to a web
server.
Ans.GET method: The foundation of HTTP/0.9 (the first implementation of the HTTP
protocol)
was the definition of the GET method that was used by a web browser to request a
specific document.
POST method: The POST method allows web browsers to send an unlimited amount of
data to a web
server by allowing them to tag it on to an HTTP request after the request headers as the
message body.
Q2. How are JSPs better than servlets?
Ans. Java programming knowledge is needed to develop and maintain all aspects of the
application, since the
processing code and the HTML elements are lumped together. b) Changing the look and
feel of the application,
or adding support for a new type of client, requires the servlet code to be updated and
recompiled. c) Its hard
to take advantage of web-page development tools when designing the application
interface. If such tools are
used to develop the web page layout, the generated HTML must then be manually
embedded into the servlet
code, a process which is time consuming, error prone, and extremely boring. Adding JSP
to the puzzle we solve
these problems.So JSPs better than servlets
Q3. Explain GET and POST method.
Ans: When a client sends a request to the server, the clients can also additional
information with the URL to
describe what exactly is required as output from the server by using the GET method.
The additional sequence
of characters that are appended to URL is called a query string. However, the length of
the query string is
limited to 240 characters. Moreover, the query string is visible on the browser and can
therefore be a security risk.
to overcome these disadvantages, the POST method can be used. The POST method
sends the data as packets
through a separate socket connection. The complete transaction is invisible because to the
client. The disadvantage
of POST method is that it is slower compared to the GET method because data is sent to
the server as separate packets.
Q4. What is HTML? What is the use of HTML?
Ans. HTML (Hyper Text Markup Language) is simply a markup language, which is used
to describe the logical structure
of a document.
Q5. Describe the role of deployment descriptors.
Ans: This is an XML file describing the servlet and other components that make up your
application, along with any
initialization parameters and container-managed security constraints that we want the
server to enforce for us. The
ejb-jar.xml or application.xml file is used as deployment descriptor.
All of the above methods (except getElementsByTagName()) can only be used against
the document
object, i.e., using the syntax : document.methodName().
Q11. What is the difference between internet & intranet?
Ans. Internet -: Internet is global network of networks. Internet is a tool for
collaborating academic research,
and it has become a medium for exchanging and distributing information of all kinds. It is
an interconnection
between several computers of different types belonging to various networks all over
global.
Intranet -: Intranet is not global. It is a mini web that is limited to user machines and
software program of
particulars organization or company.
Q12. What are the different between session and application?
Ans: SessionsSessions are something the server offers us to support user tracking, and
theyre great,
although they can take up a lot of resources on the server. Sessions preserve data between
accesses to a
Web page by the same user.
ApplicationsApplications are much like sessions, as well see, but theyre more
general
we can share data between all the JSP pages in a site using applications. In other words,
unlike
sessions, applications can be used to track multiple users at the same time.
Q13. What is the difference between web server and application server?
Ans: Web server: Web server is the software responsible for accepting browser requests,
retrieving its
content & returning its content. By default, Web browsers use port 80 for their requests.
Web servers are
often called httpd, using a UNIX convention in which daemons are named with the name
of the service
followed by the letter d. Web servers first retrieve the request using Berkeley sockets.
Most web servers on Internet today run on UNIX machines.
Application server: An application server commonly includes a web server so perhaps
we can see an
application server as an extension of a web server. In application server you can deploy a
java components
ranging from simple java application to server side business components. Usually when
we want to deploy
EJBs we will go for App servers like web-logic or web-sphere. In application server, ejbjar.xml or
application.xml file is used as deployment descriptor.
Q14. Differentiate between Java & Java scripts.
Java -:Java Programming language,is an OOP Language and development environment,
application environment, deployment environment. It is standalone programming
Language that do not require a web browser to execute.
Java script: It is a contained in the HTML source of webpage. It controls document
appearance and content.
It also manipulates embedded images and it also interacts with Applets. Its advantage is
that it is simplified,
it doesnt have to be compiled and the source code resides within our HTML document.
Q22. Explain how HTTP is used in client/server system. Further, Justify HTML is a
language of the web.
Ans: HTTP is a request-response type protocol that specifies that a client will open a
connection to a
server then send a request using a very specific format. HTTP is a language spoken
between our web
browser (client s/w) and a web server (server software) so that they can communicate
with each other and
exchange files. Client/server system is a very eager way of distributing information
across information
systems like LAN, WAN, or the Internet. A client/server system works something like
this: A server
sits in some office somewhere with a bunch of files that people might want access to.
This computer runs
a software package that listens all day long to requests over the wires. The server
software will then
accesses the server hardware, find the requested file, send it back over the wires to the
client who
requested it, and then wait for another request from the same or another client. HTML is
a simply markup
language used to define a logic structure rather than computer. The beauty of HTML of
route is that it is
generic enough that it can be read and interpreted by a web browser running on any
machine or o/s. It
only focuses on describing is responsible for adding style. So that HTML is the language
of the web.
Q23. What is EJB and give the advantage of EJB.
Ans: An EJB is a server-side component that executes specific business logic. EJBs run
on a server and
are invoked by local or remote clients. Advantage of EJB: a) Many vendor application
servers conform to
the J2EE specification allowing one to select a best-of-breed solution. b) To handle
fluctuations in resource
demand server-side resources can easily be scaled by adding or removing servers. c)
Application servers
provide access to complex services, namely transaction and security management,
resource pooling, JNDI
(Java Naming and Directory Interface), component lifecycle management, etc.
Q24. Explain the several ways of tracking users.
Ans: The several Ways of tracking users are followings:
Hidden text: It is easier way to associating information which is not directly associated
to user.
Cookies: -This is probably the most common way of tracking users on the Internet. We
can store information
in a users computer using cookies, and retrieve it when we need it. We can also specify
how long the cookie
should exist before being deleted by the browser.
Sessions: -Sessions are something the server offers us to support user tracking, and
theyre great, although they
can take up a lot of resources on the server. Preserve data between accesses to a Web page
by the same user.
Application:- Data can be shard using application can be used to track multiple users at
same time.
Q25. Briefly explain role played by CGI programming in web programming.
Ans: CGI stands for Common Gateway Interface. CGI is the part of the Web server that
can communicate
with other programs running on the server. CGI provides a gateway between a human
user with unexpected
and complex needs, and a powerful, command/logic oriented server. All CGI applications
must translate the
needs of clients into server requests, and translate server replies into meaningful wellpresented answers. The
CGI script will be responsible for processing the form data, which is filled by user and
responding to the client
in the form of dynamically generated HTML. With CGI, the Web server can call up a
program, while passing
user-specific data to the program (such as what host the user is connecting from, or input
the user has supplied
using HTML form syntax). The program then processes that data and the server passes
the programs response
back to the Web browser.
Q26. How do you create a Cookie? Explain with an example.
Ans: Cookies is the way to store information in users computer and retrieve it when we
need it. Cookies are
small text file that used by a webserver to keep tracking of users. A cookie has value in
the form of key-value pair.
They are created by user and sent to the client with the HTTP response headers. The
client saves the cookies in the
local disk and sends them along with the HTTP request headers to the server. To create
the cookies, we use the
cookies class, constructor, packing it the name of the cookie and test in the cookie. We
can also set length of time
the cookie will exits on the users computer with set MaxAge method.
We pass value in second to make the cookie last for a day we can pass a value of
24*60*60 in this way.
<HTML><HEAD> <TITLE>Setting a Cookie</TITLE> </HEAD><BODY>
<H1>Hello Cookie</H1>
<% Cookie cookie1 = new Cookie("message", "Hello!"); cookie1.setMaxAge(24 * 60 *
60);
response.addCookie(cookie1); %> </BODY> </HTML>
Q27. What is XML? Explain in brief.
Ans: Extensible markup language is a text-based markup language that enables to store
data in a structured format
by using meaningful tags. XML is a cross-platform, h/w & s/w independent markup
language. XML allows computers
to store data in a format that can be interpreted by any other computer system. XML can
be used to transfer structured
data between various systems. Xml is used as a common data interchanges format in a
number of applications.
XML is extremely simple. XML represents information as text using tags to add
structure. A tag begins with a
name sandwiched between less-than (<) and greater-than (>) characters.
Advantages of XML: a) it provides a way
of creating domain-specific vocabulary.
b) It enables smart searches.
c) It provides user-selected view of data.
HTML: - HTML stands for Hyper Text Markup Language. HTML is a very simple
language used to describe
the logical structure of a document. Actually, HTML is often called programming
language it is really not.
Programming languages are Turing-complete, or computable. That is, programming
languages can be used
to compute something such as the square root of pi or some other such task. Typically
programming languages
use conditional branches and loops and operate on data contained in abstract data
structures. HTML is much
easier than all of that. HTML is simply a markup language used to define a logical
structure rather than compute anything.
HTTP: - HTTP is a request-response type protocol. It is a language spoken between
web browser (client software)
and a web server (server software) so that can communicate with each other and
exchange files. Now let us
understand how client/server system works using HTTP. A client/server system works
something like this:
A big piece of computer (called a server) sits in some office somewhere with a bunch of
files that people
might want access to. This computer runs a software package that listens all day long to
requests over the wires.
Q32. What is CGI? Give example of CGI applications and explain anyone of them.
Ans: CGI or Common Gateway Interface is a specification which allows web users
to run programs from their
computer. CGI is the part of the Web server that can communicate with other programs
running on the server.
The Web server can call up a program, while passing user-specific data to the program.
The program then processes
that data and the server passes the programs response back to the Web browser.
Some of the possible applications of CGI are:
1) Forms: - One of the most prominent uses of CGI is in processing forms are subsets of
HTML that
allow the user to supply information forms. The forms interface makes Web browsing an
interactive process for the
user and the provider.
2) Gateways: - CGI provides a solution to the problem in the form of a gateway. We can
use a language such
as oraperl or a DBI extension to Perl to form SQL queries to read the information
contained within the database.
Once we have the information, we can format and send it to the client. In this case, the
CGI program servers as
a gateway to the Oracle database.
3) Virtual Documents: - Virtual, or dynamic, document creation is at the heart of CGI.
They are created on the fly
in response to a users information request. We can create virtual HTML, plain text,
image, and even audio documents.
Q33. What is JSP? How it is different from CGI programming?
Ans: JSP stands for Java Server Pages. It is a technology for developing web pages that
include dynamic content.
A JSP page can change its content based on any number of variable items, including the
identity of the user, the
users browser type, information provided by the user, and selections made by the user. A
JSP page contains
standard markup language elements, such as HTML tags, just like a regular web page.
JSP also contains special
JSP elements that allow the server to insert dynamic content in the page. JSP elements
can be used for a variety
of purposes, such as retrieving information from a database or registering user
preferences. JSP defines a number
of standard elements that are useful for any web application.
Q34. What are the disadvantages of hidden controls?
Ans: Storing data in hidden controls works, it is not very secure, and the data stored in
those controls
is visible if the user views the pages HTML source. We cant store data between
sessions.
Q35. Explain briefly the uses of Java Scripts.
Ans: JavaScript is a Client - Side Scripting. JavaScript changes the font size or any
other
CSS property on an element. So JavaScript plays a really big role in DHTML.
Q36.Summarize salient features of HTTP protocol.
Ans: HTTP is a protocol that is defined in several RFCs located
at the Internic. HTTP is a
request-response type protocol that specifies that a client will
open a connection to a server then send a request using a very
specific format. HTTP is a language spoken between our web
browser (client s/w) and a web server (server software) so that
they can communicate with each other and exchange files.
Client/server system is a very keen way of distributing
information across information systems like a local area network
(LAN), a wide area network (WAN), or the Internet. A client/server system works
something like this: A big hunk of computer (called a server) sits in some office
somewhere with a bunch of files that people might want access to. This computer runs a
software package that listens all day long to requests over the wires. The server
software will then accesses the server hardware, find the requested file, send it back over
the wires to the client who requested it, and then wait for another request from the
same or another client. The client software however, deals with all the underlying
client/server protocol stuff and then displays the document. Web programming is a game
of getting user input, processing that input, and returning a dynamic response.
Q37.With syntax explain the five TYPE attribute that INPUT tag defines.
Ans: The INPUT tag defines a form element that can receive user input. The TYPE
attribute
determines the specific sort of form element to be created. TYPE can be one of the
following:
1) INPUT TYPE=BUTTON: A button appears in the form. We must specify
JavaScript
code as the value of the ONCLICK attribute to determine what happens when the user
clicks the button.
Syntax :< INPUT TYPE="BUTTON" -NAME="buttonName" -VALUE=" buttonText"
ONCLICK=" JScode">
Ans. a) void addCookie(Cookie cookie): -Adds the specified cookie to the response
object
b) java.util.Enumeration getAttributeNames(): -Returns Java Enumeration of String
objects containing
the names of all the objects in this session.
c) long getCreationTime(): -Returns the time when this session was created (measured
in
milliseconds since midnight January 1, 1970 GMT).
d) long getLastAccessedTime(): -Returns the last time the client sent a request in
with this session, as the number of milliseconds since midnight January 1, 1970 GMT.
e) int getMaxInactiveInterval(): - Returns the maximum time, in seconds, which the
server will keep this session open between client accesses.
f) void removeAttribute(java.lang.String name): -Removes the object with
the specified name from this session.
Q43. What do you mean by scriptlets in JSP?
Ans: Scriptlets are the JSP components that bring all the JSP elements together.
They can contain almost any coding statements that are valid for the language
referenced in the language directive. They are executed at request time, and they
can make use of all the JSP components. The syntax for a scriptlet is as follows:
<% scriptlet source %>
Q44.What is SSL? What is the necessity of it? Explain the working of SSL.
Ans: SSL stands for
Secure Sockets Layer.
SSL is a protocol. It is developed by
Netscape, has become the
universal standard on the
Web for authenticating
Web sites to Web browser
users, and for encrypting
communications between browser users and Web servers. The main role of SSL
is to provide security for Web traffic. Security includes onfidentiality, message
integrity, and authentication. The working of SSL is: SSL has two distinct entities,
server and client. The client is the entity that initiates the transaction, whereas the
server is the entity that responds to the client and negotiates which cipher suites
are used for encryption. In SSL, the Web browser is the client and the Web-site
server is the server. Three protocols lie within SSL, the Handshake Protocol,
the Record Protocol, and the Alert Protocol. The client authenticates the server
during the Handshake Protocol. When the session is initiated and the handshake
is complete, the data transfer is encrypted during the Record Protocol phase.
If there are any alarms at any point during the session, the alert is attached to
the questionable packet and handled according to the Alert Protocol.
Q45. Write a JavaScript program to pop up an alert message.
Ans: <HTML> <HEAD> <Script language=Java Script> alert (This is an alert
message for java script)
</SCRIPT></HEAD><BODY></BODY></HTML>
Q46.Explain in brief how to use hidden controls in a web page. Give an example.
Further,
list the advantages and disadvantages of hidden controls.
Ans: Using HTML hidden control is an easy way to store data in a webpage.
The user set the text to store in a hidden control in a text field.
The code stores the text, the user type in the hidden control.
Advantages: A hidden control in a Web page is the easiest way of associating
some information with the user thats not directly accessible to him. Hidden
controls to store data in the Web page sent to the browser and then sent back to the server
Disadvantages: Storing data in hidden controls is not very secure. The data stored in
those
controls is visible if the user views the pages HTML source. We cant store data
between sessions.
Q47.Explain the ordered lists and unordered lists.
Ans: Ordered lists: The OL tag displays an ordered, or numbered, list. The default
numbering
style is determined by the browser, but you can use the tags TYPE attributes to change
the
numbering sequence and numbering style. Use the LI tag to designate the individual list
items.
Syntax: <OL -START="value"- TYPE= "A" |"a"| "I" |"I "|"1" -CLASS= "styleClass
ID="namedPlaceOrStyle" LANG=ISO -STYLE=style > </OL>.
Unordered list: The UL tag displays a bulleted list. You can use the tags TYPE
attribute to change the bullet style. Use the LI tag to designate the individual list items in
the list.
Syntax: <UL TYPE="CIRCLE"|"DISC"|"SQUARE" -CLASS="styleClass"
ID="namedPlaceOrStyle"LANG= ISO -STYLE=style > </UL>.
Q48.Write HTML script to display Hello world, welcome to the
world of HTML, the title as world of HTML.
Ans: <HTML><HEAD><TITLE>world of HTML</TITLE><Script language=Java
Script>
Hello world, welcome to the world of HTML</SCRIPT></HEAD><BODY></BODY>
</HTML>
Q49.Write a JSP program which displays different message to the user based on the
time of day.
Ans: <%@ taglib prefix=c uri=http://java.sun.com/jstl/core %> <html> <body
bgcolor=white>
<jsp:useBean id=clock class=java.util.Date /> <c:choose><c:when test=$
{clock.hours < 12}>
<h1>Good morning!</h1></c:when><c:when test=${clock.hours < 18}><h1>Good
day!</h1>
</c:when><c:otherwise><h1>Good evening!</h1></c:otherwise></c:choose>Welcome
to our site, open 24 hours a day.</body></html>.
i)