Anna University
DEPARTMENT OF INFORMATION TECHNOLOGY
IT2353 –WEB TECHNOLOGY
Regulation 2008
Two Marks with Answers
Unit 3
SUBJECT CODE : IT2353
SUBJECT NAME:WEB TECHNOLOGY
Year / Class : 111rd yr IT
Semester : 6th sem
UNIT - III
PART – A
Two Marks with Answers
1. List any two keyboard events?
• onKeypress
• onKeyUp
• onKeyDown
2. List any two mouse events?
• onMouseUp
• onMouseDown
• onMouseOver
• onClick
3. What are Servlets?
A small program that runs on a server, the term usually refers to a Java applet that runs within a Web server environment. This is analogous to a Java applet that runs within a Web browser environment.
Java servlets are becoming increasingly popular as an alternative to CGI programs. The biggest difference between the two is that a Java applet is persistent. This means that once it is started, it stays in memory and can fulfill multiple requests. In contrast, a CGI program disappears once it has fulfilled a request. The persistence of Java applets makes them faster because there\'s no wasted time in setting up and tearing down the process.
4. What are Applets?
A program designed to be executed from within another application. Unlike an application, applets cannot be executed directly from the operating system. With the growing popularity of OLE (object linking and embedding), applets are becoming more prevalent. A well-designed applet can be invoked from many different applications.
Web browsers, who are often equipped with Java virtual machines, can interpret applets from Web servers. Because applets are small in files size, cross-platform compatible, and highly secure (can’t be used to access users\' hard drives), they are ideal for small Internet applications accessible from a browser.
5. What do you mean by Server-side?
Occurring on the server side of a client-server system. For example, on the World Wide
Web, CGI scripts are server-side applications because they run on the Web server. In contrast, JavaScript scripts are client-side because they are executed by your browser (the client). Java applets can be either server-side or client- side depending on which computer (the server or the client) executes them.
6. Explain the life cycle methods of a Servlet.
The javax.servlet.Servlet interface defines the three methods known as life-cycle method.
public void init(ServletConfig config) throws ServletException
public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException public void destroy()
First the servlet is constructed, then initialized wih the init() method.
Any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet.
The servlet is removed from service, destroyed with the destroy() methid, then garbaged collected and finalized.
7. What is the difference between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?
The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a \"/\" it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot accepts relative paths. All path must sart with a \"/\" and are interpreted as relative to curent context root.
8. Explain the directory structure of a web application.
The directory structure of a web application consists of two parts.
A private directory called WEB-INF
A public resource directory which contains public resource folder.
WEB-INF folder consists of
1. web.xml
2. classes directory
3. lib directory
9. What are the common mechanisms used for session tracking?
Cookies
SSLsessions
URL- rewriting
10. Explain about Session tracking.
A session is basically a conversation between a browser and a server. All the above technologies can save information for the current session for a particular user visiting a site.
The session is important, as H1TP is a stateless protocol. This means that the connection between web server and a web browser is not automatically maintained, and that the state of a web session is not saved.
State is a general term that includes \"everything about your situation\" and the specifics vary based on the application. In a word processor, the state of the application would include which windows are open, where they are on the screen, and what files you most recently used.
In a web application, the state would include any data that you had entered, the results of any queries that you had run, and your security access information (e.g. whether you have logged in to the site).
11. Explain ServletContext
ServletContext interface is a window for a servlet to view it\'s environment. A servlet can use this interface to get information such as initialization parameters for the web applicationor servlet container\'s version. Every web application has one and only one ServletContext and is accessible to all active resource of that application
12. What is preinitialization of a servlet?
A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The servlet specification defines the <load-on-startup> element, which can be specified in the deployment descriptor to make the servlet container load and initialize the servlet as soon as it starts up. The process of loading a servlet before any request comes in is called preloading or preinitializing a servlet.
13. What is the difference between Difference between doGet() and doPost()?
A doGet() method is limited with 2k of data to be sent, and doPost() method doesn\'t have this limitation. A request string for doGet() looks like the following:
http://www.allapplabs.com/svt1?p1=v1&p2=v2&...&pN=vN
doPost() method call doesn\'t need a long text tail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and it\'s impossible to guess the data transmitted to a servlet only looking at a request string.
14. What is the difference between HttpServlet and GenericServlet?
A GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and adds support for doGet(), doPost(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1).
Both these classes are abstract.
15. What is the difference between ServletContext and ServletConfig?
ServletContext: Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized
ServletConfig: The object created after a servlet is instantiated and its default constructor is read. It is created to pass
No comments:
Post a Comment