WTAD Solutions 4

      No Comments on WTAD Solutions 4
Mobile Apps Category (English)728x90

WTAD Solutions 4


45.Briefly discuss the following HTTP 1.1 request headers:

  1. i) Accept ii) Accept-Charset iii) Host iv) Accept-Language v) Authorization vi) Cookie vii) User-Agent

Ans: there are various httpheader in servlet are as follow.

  • Accept
  • Accept Charset
  • Accept Language
  • Authoriazation
  • Cookies
  • Host
  • User Agent



This header specifies the MIME types that the browser or other clients can handle. A servlet that can return a resource in more than one format can examine the Accept header to decide which format to use. For example, images in PNG format have some compression advantages over those in GIF, but not all browsers support PNG. If you have images in both formats, your servlet can call request.getHeader(“Accept”), check for image/png, and if it finds a match, use blah.png filenames in all the IMG elements it generates. Otherwise, it would just use blah.gif.



This header indicates the character set the browser can use.




This header specifies the client’s preferred languages in case the servlet can produce results in more than one language. The value of the header should be one of the standard language codes such as en, en-us, da, etc.



In HTTP 1.1, browsers and other clients are required to specify this header, which indicates the host and port as given in the original URL. Because of the widespread use of virtual hosting (one computer handling Web sites for multiple domain names), it is quite possible that the server could not otherwise determine this information. This header is not new in HTTP 1.1, but in HTTP 1.0 it was optional, not required.



This header returns cookies to servers that previously sent them to the browser. Never read this header directly because doing so would require cumbersome low-level parsing; use request.getCookies instead



This header is used by clients to identify themselves when accessing password-protected Web pages.



This header identifies the browser or other client making the request and can be used to return different content to different types of browsers. Be wary of this use when dealing only with Web browsers; relying on a hard-coded list of browser versions and associated features can make for unreliable and hard-to-modify servlet code. Whenever possible, use something specific in the HTTP headers instead. For example, instead of trying to remember which browsers support gzip on which platforms, simply check the Accept-Encoding header. However, the User-Agent header is quite useful for distinguishing among different categories of client. For example, Japanese developers might see whether the User-Agent is an Imode cell phone (in which case they would redirect to a chtml page), a Skynet cell phone (in which case they would redirect to a wml page), or a Web browser (in which case they would generate regular HTML).


46.Explain the following methods of HttpServletResponse with examples.

  1. i) setContentType() ii) setStatus() iii) sendError() iv) sendRedirect() v) setContentLength()
  2. vi) encodeURL() vii) isCommited(




  • It Use the setContentType method of HttpServlet Response for this task.
  • The MIME type for JPEG.

Ex: Response.setContentType(“image/jpeg”);


  • The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

(III) sendError():-

  • The 404 status code is used when no document is found on the server.
  • The sendError method sends a status code (usually 404) along with
  • a short message that is automatically formatted inside an HTML
  • document and sent to the client.


  • The 302 status code directs the browser to connect to a new locatin.,The sendRedirect
  • method generates a 302 response along with aLocation header giving the URL of the new document. Either anabsolute or a relative URL is permitted; the system automatically
  • translates relative URLs into absolute ones before putting them in theLocation header


(V) setContentLength():-

This method setd the content-length header,which is useful the browser support presidents HHTP coonection.

(VI)encode URL:-

Encodes a URL string. These method overloads can be used to encode the entire URL, including query-string values. To encode or decode values outside of a web application,

(VII) isCommited().:-

thesse method specify or look up a cooment associated with the cookie.with version 0 cookie .the comment is used purely for information purpose on the server it is not sent to the client.


Answer the following:

  1. We can save external JavaScript file with ____ extension.

Ans: .js

  1. Error between 400 and 499 represents ____.

Ans: client error

  1. If the cookies are disabled on clinet-side, the alternate mechanism that can be used is _____ .
    1. URL Rewriting b. Forcefully enable the cookies c. Use of beans d. None of the above

Ans:d None of above

  1. JavaScript is created by______ . (Sun, Microsoft, Netscape)

Ans: Netscape

  1. In Javascript, eval(“2 + 0.56”) returns ______.


  1. In servlet, _____ method is used with session object to store information in a session.

Ans: setAttribute

  1. CGI Stands for __________.

Ans:Common Gateway Interface

  1. In Javascript, eval(“24 + 0.56”) returns ______.

Ans: 24.56

  1. HTML elements with no content are called _______ elements.


  1. Java is _______________and JavaScript is ___________________.

Ans:object oriented language and popular programming language

  1. _________ is only property of string object in JavaScript.



  1. Error between 500 and 599 represents ____.

Ans server error

  1. JavaScript is compiled and executed at client. (True / False)

Ans :false

Javascript is a language of objects in not complied and runs on client machine

  1. In HTML, <ol> tag is used to create list items with bullets. (True / False)


In html ol tag is used to create list items with numbers

  1. We must configure and map all jsp files into web.xml. (True / False)


  1. JavaScript Ignores White Space. (True or False)


  1. What will be assign in variable mca by following JavaScript var mca = parseInt(“0xff”) ;


  1. What kind of information 400-499 status code provides?

Ans:Not found

  1. Error between 100 and 199 represents ____.

Ans :informational error

  1. What is the use of <load-on-startup> element of web.xml?

Ans: load-on-startup means that the servlet must be loaded and initialized on startup of the webapp (i.e. as soon as it is deployed, without waiting for a request to the servlet). The number indicates the order of the initialisations. If another servlet has 1, it will be loaded before. If another has 3, it will be loaded after.


  1. The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the correct answer. A. HttpServletRequest B. HttpServletResponse C. ServletConfig D. ServletContext



Ans: httpServletResponse










Leave a Reply