WEB TECHNOLOGIES AND ADVANCED JAVA VIVA
Question & Answers
Q: After I have edited an HTML file, I cannot view the result in
my browser. Why?
A: Make sure that you have saved the file with a proper name and extension like "c:\mypage.htm". Also make sure that you use the same name when you open the file in your browser.
A: Make sure that you have saved the file with a proper name and extension like "c:\mypage.htm". Also make sure that you use the same name when you open the file in your browser.
Q: I have edited an HTML file, but the changes don't show in the
browser. Why?
A: A browser caches pages so it doesn't have to read the same page twice. When you have modified a page, the browser doesn't know that. Use the browser's refresh/reload button to force the browser to reload the page.
A: A browser caches pages so it doesn't have to read the same page twice. When you have modified a page, the browser doesn't know that. Use the browser's refresh/reload button to force the browser to reload the page.
Q: What browser should I use?
A: You can do all the
training with all of the well-known browsers, like Internet Explorer, Firefox,
Netscape, or Opera. However, some of the examples in our advanced classes
require the latest versions of the browsers.
Q: Does my computer have to run Windows? What about a Mac?
A: You can do all your training on a non-Windows computer like a Mac.
A: You can do all your training on a non-Windows computer like a Mac.
1. What is XML?
(ans) XML is the Extensible Markup Language. It improves
the functionality of the Web by letting you identify your information in a more
accurate, flexible, and adaptable way.
It is extensible because it is not a fixed format like
HTML (which is a single, predefined markup
language). Instead, XML is actually a metalanguage—a
language for describing other languages—which lets you design your own markup
languages for limitless different types of documents. XML can do this because
it's written in SGML,
the international standard metalanguage for text document markup (ISO 8879).
2.What is a markup language?
(ans) A markup language is a set of words and symbols
for describing the identity of pieces of a document (for example ‘this is a
paragraph’, ‘this is a heading’, ‘this is a list’, ‘this is the caption of this
figure’, etc). Programs can use this with a stylesheet to create output for
screen, print, audio, video, Braille, etc.
Some markup languages (eg those used in wordprocessors)
only describe appearances (‘this is italics’, ‘this is bold’), but this method
can only be used for display, and is not normally re-usable for anything else.
XML is sometimes referred to as ‘self-describing data’
because the names of the markup elements should represent the type of content
they hold.
3. What is XML for (aka ‘Where should I use XML’)?
(ans) Its goal is to enable generic SGML
to be served, received, and processed on the Web in the way that is now
possible with HTML. XML has been designed for ease of implementation and for
interoperability with both SGML and HTML.
SeeWhere's the spec?
Despite early attempts,
browsers never allowed other SGML, only HTML (although there were unknownplugins), and they allowed
it (even encouraged it) to be corrupted or broken, which held development back
for over a decade by making it impossible to program for it reliably. XML fixes
that by making it compulsory to stick to the rules, and by making the rules
much simpler than SGML.
But XML is not just for Web pages: in fact it's very
rarely used for Web pages on its own because browsers still don't provide
reliable support for formatting and transforming it. Common uses for XML
include:
Information identification
because you can define your own markup, you can define
meaningful names for all your information items.
Information storage
because XML is portable and non-proprietary, it can be
used to store textual information across any platform. Because it is backed by
an international standard, it will remain accessible and processable as a data
format.
Information structure
XML can therefore be used to store and identify any kind
of (hierarchical) information structure, especially for long, deep, or complex
document sets or data sources, making it ideal for an information-management
back-end to serving the Web. This is its most common Web application,
with a transformation system to serve it as HTML until such time as browsers
are able to handle XML consistently.
Publishing
The original goal of XML as defined in the quotation at
the start of this section. Combining the three previous topics (identity,
storage, structure) means it is possible to get all the benefits of robust
document management and control (with XML) and publish to the Web (as HTML) as
well as to paper (as PDF) and to other formats (eg Braille, Audio, etc) from a
single source document by using the appropriate stylesheets.
Messaging and data transfer
XML is also very heavily used for enclosing or
encapsulating information in order to pass it between different computing
systems which would otherwise be unable to communicate. By providing a lingua
franca for data identity and structure, it provides a common envelope for
inter-process communication (messaging).
Web services
Building on all of these, as well as its use in
browsers, machine-processable data can be exchanged between consenting systems,
where before it was only comprehensible by humans (HTML). Weather services,
e-commerce sites, blog newsfeeds, AJaX sites, and
thousands of other data-exchange services use XML for data management and
transmission, and the web browser for display and interaction.
4. What is SGML?
(ans)SGML is the Standard Generalized Markup Language (ISO 8879:1986), the international standard for
defining descriptions of the structure of different types of electronic
document. There is an SGML FAQ from David Megginson at http://math.albany.edu:8800/hm/sgml/cts-faq.htm
SGML is very large, powerful, and complex. It has been
in heavy industrial and commercial use for nearly two decades, and there is a
significant body of expertise and software to go with it.
XML is a lightweight cut-down version of SGML which
keeps enough of its functionality to make it useful but removes all the
optional features which made SGML too complex to program for in a Web
environment.
5. What is HTML?
(ANS)HTML is the HyperText
Markup Language (RFC
1866), which started as a small application of question A.4, SGML for the
Web, originating with Tim
Berners-Lee at CERN in 1989–90.
It defines a very simple class of report-style
documents, with section headings, paragraphs, lists, tables, and illustrations,
with a few informational elements, but very few presentational elements [10], plus
some hypertext and multimedia. See the question on extending HTML.
The current recommendation is to use the XML version, XHTML. There is a
HTML and XHTML FAQ maintained by Steven Pemberton at http://www.w3.org/MarkUp/2004/xhtml-faq
6.Aren't XML, SGML, and HTML all the same thing?
(ans) Not quite; SGML is the
mother tongue, and has been used for describing thousands of different document
types in many fields of human activity, from transcriptions of ancient Irish manuscripts to the technical documentation for stealth bombers,
and from patients' medical and clinical records
to musical notation. SGML is very
large and complex, however, and probably overkill for most common office
desktop applications.
XML is an abbreviated version of SGML, to make it easier
to use over the Web, easier for you to define your own document types, and
easier for programmers to write programs to handle them. It omits all the
complex and less-used options of SGML in return for the benefits of being
easier to write applications for, easier to understand, and more suited to
delivery and interoperability over the Web. But it is still SGML, and XML files
may still be processed in the same way as any other SGML file (see the question
on XML
software).
HTML
is just one of many SGML or XML applications—the one most frequently used on
the Web.
Technical readers will find it more useful to think of
XML as being SGML−− rather than HTML++.
7.Who is responsible for XML?
(ans) XML is a project of the World Wide Web Consortium (W3C), and the
development of the specification is supervised by an XML Working Group. A
Special Interest Group of co-opted contributors and experts from various fields
contributed comments and reviews by email.
XML is a public format: it is not a proprietary
development of any company, although the membership of the WG and the SIG
represented companies as well as research and academic institutions. The v1.0
specification was accepted by the W3C as a Recommendation on Feb 10, 1998.
8.Why is XML such an important development?
(Ans) It removes two constraints which were holding back
Web developments:
dependence on
a single, inflexible document type (HTML) which was
being much abused for tasks it was never designed for;
the complexity
of full question A.4, SGML,
whose syntax allows many powerful but hard-to-program options.
XML allows the flexible development of user-defined
document types. It provides a robust, non-proprietary, persistent, and
verifiable file format for the storage and transmission of text and data both
on and off the Web; and it removes the more complex options of SGML, making it
easier to program for.
9.Why not just carry on extending HTML?
(ans) HTML was
already overburdened with dozens of interesting but incompatible inventions
from different manufacturers, because it provides only one way of describing
your information.
XML allows groups of people or organizations to question
C.13, create
their own customized markup applications for exchanging information in
their domain (music, chemistry, electronics, hill-walking, finance, surfing,
petroleum geology, linguistics, cooking, knitting, stellar cartography,
history, engineering, rabbit-keeping, question C.19, mathematics, genealogy, etc).
HTML is now well beyond the limit of its usefulness as a
way of describing information, and while it will continue to play an important
role for the content it currently represents, many new applications require a
more robust and flexible infrastructure.
10.Why should I use XML? (aka ‘What is XML for?)
(ans) Here are a few reasons for using XML (in no
particular order). Not all of these will apply to your own requirements, and
you may have additional reasons not mentioned here (if so, please let the
editor of the FAQ know!).
·
XML can be used to describe and
identify information accurately and unambiguously, in a way that computers can
be programmed to ‘understand’ your information (well, at least manipulate as if
they could understand it).
·
XML allows documents which are
all the same type to be created and handled consistently and without structural
errors, because it provides a standardised way of describing, controlling, or
allowing/disallowing particular types of document structure. [Note that this
has absolutely nothing whatever to do with formatting, appearance, or the
actual text or data content of your documents, only the structure of them. If
you want styling or formatting, see question C.24, ‘How do I control
formatting and appearance?’.]
·
XML provides a robust and
durable format for information storage and transmission. Robust because it is
based on a proven standard, and can thus be tested and verified; durable
(persistent) because it uses plain-text file formats which will outlast
proprietary binary ones.
·
XML provides a common syntax
for messaging systems for the exchange of information between applications.
Previously, each messaging system had its own format and all were different,
which made inter-system messaging unnecessarily messy, complex, and expensive.
If everyone uses the same syntax it makes writing these systems much faster and
more reliable.
·
XML is free. Not just free of
charge (free as in beer) but free of legal encumbrances (free as in speech). It
doesn't belong to anyone, so it can't be hijacked or pirated. And you don't
have to pay a fee to use it (you can of course choose to use commercial
software to deal with it, for lots of good reasons, but you don't pay for XML
itself).
·
XML information can be
manipulated programmatically (under machine control), so XML documents can be
pieced together from disparate sources, or taken apart and re-used in different
ways. They can be converted into any other format with no loss of information.
·
XML lets you separate form
(appearance) from content. Your XML file contains your document information
(text, data) and identifies its structure: your formatting and other processing
needs are identified separately in a stylesheet or
processing system. The two are combined at output time to apply the required
formatting to the text or data identified by its structure (location, position,
rank, order, or whatever).
·
Any of the Design Goals listed
in the XML Specification.
11. Where do I find more information about XML?
(ans) Online, there's the XML Specification
and the ancillary documentation available from the W3C;
Robin Cover's SGML/XML Web pages with
an extensive list of online reference material and links to software; and a summary and condensed FAQFPRIVATE Google
or other search engine.
For offline resources, see the lists of books, articles,
and software for XML in Robin Cover's SGML and XML Web pages. That
site should always be your first port of call.
The events listed below are the ones I have been told
about. Please mail me if you come
across others: there are many other XML events around the world, and most of
them are announced on the mailing lists and
newsgroups.
12.Where can I discuss implementation and development of
XML?
(Ans) The two principal online support media are Usenet
newsgroups and mailing lists. The IRC network is also used to some extent, and
most individual projects and programs have their own topic-specific
bulletin-boards on their web sites.
For off-line support, see question A.11, ‘Where do I find more
information about XML?’ for details of conferences and summerschools.
·
The Usenet newsgroups are comp.text.xml and to a certain extent comp.text.sgml. Ask your Internet Provider for
access to these, or use a Web interface like Google
Groups. If your browser or mailer doesn't provide newsreading facilities,
install one that does, or (better) use a standalone newsreader.
·
The general-purpose mailing
list for public discussion is XML-L:
to subscribe, visit the Web site
and click on the link to join.
·
For those developing software
components for XML there is the xml-dev
mailing list. You can subscribe by sending a 1–line mail message to xml-dev-request@lists.xml.org saying just
SUBSCRIBE. Note that this list is for those people actively involved in
developing resources for XML. It is not for general information about XML (use
the XML-L list above for that).
·
The XSL-List is for for
discussing XSL (both XSLT and XSL:FO). For details of how to subscribe, see http://www.mulberrytech.com/xsl/xsl-list.
13. What is the difference between XML and C or C++ or
Java?
(ans) C and C++ (and other languages like FORTRAN, or
Pascal, or Visual Basic, or Java or hundreds more) are programming languages
with which you specify calculations, actions, and decisions to be carried out
in order:
mod curconfig[if
left(date,6) = "01-Apr",
t.put "April Fool!",
f.put days('31102005','DDMMYYYY') -
days(sdate,'DDMMYYYY')
" more shopping days to
Samhain"];
XML is a markup specification language with which you
can design ways of describing information (text or data), usually for storage,
transmission, or processing by a program. It says nothing about what you should
do with the data (although your choice of element names may hint at what they
are for):
<part
num="DA42" models="LS AR DF HG KJ"
update="2001-11-22">
<name>Camshaft end bearing retention
circlip</name>
<image drawing="RR98-dh37"
type="SVG" x="476"
y="226"/>
<maker id="RQ778">Ringtown
Fasteners Ltd</maker>
<notes>Angle-nosed insertion tool
<tool
id="GH25"/> is required
for the removal
and replacement of this
part.</notes>
</part>
On its own, an SGML or XML file (including HTML) doesn't
do anything. It's a data format which just sits there until you run a program
which does something with it. See also the question about how to run or execute
XML files.
: Are
sessions created on the server side?
A: A servlet session is created and
stored on the server side. The servlet container keeps track of all the
sessions it manages and fulfils servlet API requests to get
HttpSessions
, manipulate object data stored with
them and trigger event callbacks.
To the maintain the session, Web
clients must pass back a valid session identifier as a cookie header value or
dynamically generated URL parameter. In this sense, the session is also stored
by the client, but only as a token reference.
Q: Can I
create a session with GenericServlet?
A: There are no protocol-specific
features in
GenericServlet
, which is an implementation of the basic, general purpose Servlet
interface. Servlet-based sessions
are designed only for interactions using the HTTP protocol, which has two key
features necessary for a servlet container to simulate continuous user
sessions: cookies and URL-based navigation, which supports URL-rewriting. The
servlet API therefore places the HttpSession
interface in the javax.servlet.http
package, and session references are
only available through classes in this package.
Q: How can I
assemble data from multiple input forms?
A: First, it is best to use a single
servlet to handle each form submission. A single servlet for all input would be
too complicated. Give each servlet responsibility to validate a single form
input, and pass the error cases on to JSP documents that explain the problem
and allow users to amend the input.
Servlet concepts
Q: What's the
difference between applets and servlets?
A: There are many fundamental
differences between
Applet
and Servlet
classes, the Java API documentation for the two types will show you they have
little in common.
Applets are essentially graphical
user interface (GUI) applications that run on the client side in a network
environment, typically embedded in an HTML page. Applets are normally based on
Abstract Windowing Toolkit components to maintain backward-compatibility with
the widest range of browsers' Java implementations. The application classes are
downloaded to the client and run in a Java Virtual Machine provided by the
browser, in a restrictive security environment called a "sandbox".
Servlets are used to dynamically
generate HTTP responses and return HTML content to Web browsers on the server
side. Servlets are often used to validate and process HTML form submissions and
control a series of user interactions in what is known as a Web application.
Servlets can be used to control all aspects of the request and response
exchange between a Web browser and the server, called a servlet container.
Q: How can I
write a servlet using Javascript?
A: Java servlets is a server side
technology that delivers dynamic content to Web browsers and other clients.
Javascript is also delivered by a Web server, but the code is only interpreted
and executed after it has been downloaded by the Web browser. This means that
it is not possible to write servlet code in Javascript.
It is possible to include
Javascript in the output of servlets and Java Server Pages, just like standard
Web pages. It is also possible to dynamically generate Javascript using a
servlet and use it as the source for a script tag, though this is only
advisable in rare cases.
Q: How does
the JVM execute a servlet compared with a regular Java class?
A: Servlets are standard Java classes
and are executed by the Java Virtual Machine in exactly the same way as any
other. However, the environment or context in which servlets are executed is
different. A servlet is not invoked directly through a
main
method, the class is loaded and run
by a servlet container.
Can I include normal Java classes
in servlets?
A: Any Java class can be used in a Web
application, provided you make the classes available to the servlet container
at runtime. The Java API classes can be used directly by adding import
statements to your servlet class. Other supporting classes can also be
imported, but these classes must be added to the
classes
or lib
directory of your application.
If you need to configure the
supporting classes, this can be done with standard servlet configuration
features using the
ServletConfig
and ServletContext
objects available to the init(ServletConfig)
method.
Q: How can I
tell when a servlet is instantiated?
A: A servlet must be instantiated
before it is brought into service by the servlet container, so one way to check
is to make a request to the servlet and check the response. If you need to
check indirectly, you can override the
init(ServletConfig)
method and add log(String)
statements to it. This method is
called after the servlet container has instantiated the servlet before it is
brought into service.
Q: What is
URL-rewriting?
A: URL-rewriting is a way of
maintaining a session between an HTTP client and a servlet container which does
not use cookies. Rather than exchange a session ID in a cookie, the servlet
container includes it in the hyperlink URLs it generates for servlets and JSP.
: Are
servlets multi-threaded?
A: Yes, servlets are normally
multi-threaded. The servlet container allocates a thread for each new request
for a single servlet without any special programming. Each thread of your
servlet runs as if a single user were accessing it alone, but you can use
static variables to store and present information that is common to all
threads, like a hit counter for instance.
How
can I pass values between JSPs without using sessions?
A: There are four main alternatives to
full session-based transfer of data values, two of them use features of the
session tracking API: cookies and URL-rewriting, detailed below.
What is JavaServer
Pages technology?
JavaServer Pages (JSP) technology provides a simplified,
fast way to create web pages that display dynamically-generated content. The
JSP specification, developed through an industry-wide initiative led by Sun
Microsystems, defines the interaction between the server and the JSP page, and
describes the format and syntax of the page.
How does the JavaServer Pages technology work?
JSP pages use XML tags and scriptlets written in the Java
programming language to encapsulate the logic that generates the content for
the page. It passes any formatting (HTML or XML) tags directly back to the
response page. In this way, JSP pages separate the page logic from its design
and display.
JSP technology is part of the Java technology family. JSP pages are compiled into servlets and may call JavaBeans components (beans) or Enterprise JavaBeans components (enterprise beans) to perform processing on the server. As such, JSP technology is a key component in a highly scalable architecture for web-based applications.
JSP pages are not restricted to any specific platform or web server. The JSP specification represents a broad spectrum of industry input.
What is a servlet?JSP technology is part of the Java technology family. JSP pages are compiled into servlets and may call JavaBeans components (beans) or Enterprise JavaBeans components (enterprise beans) to perform processing on the server. As such, JSP technology is a key component in a highly scalable architecture for web-based applications.
JSP pages are not restricted to any specific platform or web server. The JSP specification represents a broad spectrum of industry input.
A servlet is a program written in the Java programming
language that runs on the server, as opposed to the browser (applets). Detailed
information can be found at http://java.sun.com/products/servlet.
Why do I need JSP technology if I already have servlets?
JSP pages are compiled into servlets, so theoretically you
could write servlets to support your web-based applications. However, JSP
technology was designed to simplify the process of creating pages by separating
web presentation from web content. In many applications, the response sent to
the client is a combination of template data and dynamically-generated data. In
this situation, it is much easier to work with JSP pages than to do everything
with servlets.
Where can I get the most current version of the JSP
specification?
The JavaServer Pages 2.1 specification is available for
download from here.
How does the JSP specification relate to the Java Enterprise Edition 5
Platform?
The JSP 2.1 specification is an important part of the Java EE 5 Platform. Using JSP and
Enterprise JavaBeans technologies together is a great way to implement
distributed enterprise applications with web-based front ends.
Which web servers support JSP technology?
There are a number of JSP technology implementations for
different web servers. The latest information on officially-announced support
can be found at http://java.sun.com/products/jsp/industry.html.
Is Sun providing a reference implementation for the JSP
specification?
The GlassFish project is Sun's free, open-source Java EE 5
implementation. It includes an implementation of JSP technology version
2.1. You can download GlassFish builds from https://glassfish.dev.java.net/.
How is JSP technology different from other products?
JSP technology is the result of industry collaboration and
is designed to be an open, industry-standard method supporting numerous
servers, browsers and tools. JSP technology speeds development with reusable
components and tags, instead of relying heavily on scripting within the page
itself. All JSP implementations support a Java programming language-based
scripting language, which provides inherent scalability and support for complex
operations.
Where do I get more information on JSP technology?
The first place to check for information on JSP technology
is http://java.sun.com/products/jsp/.
This site includes numerous resources, as well as pointers to mailing lists and
discussion groups for JSP technology-related topics.
SOURCE:PVPSIT FOR JNTU