Sie sind auf Seite 1von 8

August 2011 Bachelor of Science in Information Technology (BScIT) Semester 4 BT0083 Server Side Programming - Theory 4 Credits

(Book ID: B1088)

Assignment Set 1 (60 Marks)

Answer all questions 1. What is HTTP? How does it work?

10 x 6 = 60

Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems.[1] HTTP is the foundation of data communication for the World Wide Web.
http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol HTTP is a client-server protocol by which two machines can communicate over a TCP/IP connection. An HTTP server is a program that listens HTTP requests on through machines port.

1. An HTTP client opens a TCP/IP connection to the server via a socket. 2. Transmits a request for a document, then waits for a reply from the server. 3. Once the request-reply sequence is completed, the socket is closed. So the HTTP protocol is a transactional one. The lifetime of a connection corresponds to a single request-reply sequence; which means it will maintain the state of previous request.

HTTP is the protocol used for document exchange in the World-Wide-Web. Everything that happens on the Web happens over HTTP transactions. TCP/IP networking and HTTP are the two essential components that make the Web work. In order to write the software that accesses the Web (like a Web browser, or a custom Web client) you need a basic understanding of both.

When we open a URL within the browser, the browser figures out from the URL, what the HTTP server's host machine and port are, as well as the document path for the document we request from the server. Subsequently, an HTTP request is delivered for that document and the appropriate connection via TCP/IP will be made with the server. Then the client (the browser) will send the request, and wait for the server to respond with an HTTP response and the requested document. If all goes fine, the browser will arrange to display the document on our desktop window. Suppose you type the URL of the previous example, http://www.mniop.org/admission.html on your mozilla URL address text box. Here's what the request will look like.

It suggests the document admission.html on the server at www.mniop.org and port 80. Protocol: Tells the server which communication protocol will be used. Server: Indicates a unique name for the physical server you are looking for. This name maps to an IP address of 32 bits and in the form of aaaa.bbbb.cccc.dddd. It is in the form of numeric and you put any IP address for this server but must be unused one. Port: It is optional because the server uses default port as per the protocol used. o For example HTTP 80, FTP 21, SMTP- 25, TELNET 23, POP3 110 etc. Resource: This represents requested page contents. It could be HTML, JSP, Servlet, PDF or any other pages. By default the server looks for index.html, if resource is not mentioned. Query String: It is the additional information generally passed on along with the requested page. If we use GET method we see information added in the URL at the end, starting with a question mark (?), with each parameter separated by &.

After execution you can see the header information using various methods, which give output in the following format. 2. Differentiate ServletContext and ServletConfig.

ServletContext
Set and store attributes that other servlets in the context can access.

ServletConfig it is used to pass deploy-time info to servlet and configured in the deployment descriptor file.

It returns the current context of a web it is used to access ServletContext application running in a particular JVM. It is within the Servlet element in if the web application is distributed,it is Deployment descriptor. one per JVM. It is accessed by using It is used to access the <context-param> getServletConfig().getInitParameter("myn elements configured in deployment ame"); descriptor. It is available only to the servlet in which It is accessed by using init-param is configured. getServletContext().getInitParameter("myn ame"); It is available to any servlet or jsp that is part of web application.

3. What are the various methods of HttpServletResponse interface?


4.

Method addCookie(Cookie) encodeRedirectURL(String)

Description Adds the specified cookie to the response. Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.

sendError(int)

Sends an error response to the client using the specified status code and a default message. Sends a temporary redirect response to the client using the specified redirect location URL. Adds a field to the response header with the given name and datevalued field. Adds a field to the response header with the given name and value.

sendRedirect(String)

setDateHeader(String, long)

setHeader(String, String)

setIntHeader(String, int)

Adds a field to the response header with the given name and integer value. Sets the status code for this response.

setStatus(int)

5. What is an Exception? Explain the keywords used for exception handling.

Exceptions provide a more natural and elegant way to handle errors. Exceptions allow you to separate error-handling code from normal code, which makes for cleaner, more readable applications. When an exception occurs, it causes the flow of program execution to be transferred to a pre-designated

"catcher" block of code. The exception carries with it an object that contains information about the situation that caused the exception.

The following are the Five keywords used in exception handling: try: Identifies a block of statements within which an exception might be thrown. catch: Must be associated with a try statement and identifies a block of statements that can handle a particular type of exception. The statements are executed if an exception of a particular type occurs within the try block. finally: must be associated with a try statement and identifies a block of statements that are executed regardless of whether or not an error occurs within the try block throw: You can throw your own exceptions with throw statement. All methods use the throw statement to throw an exception. The throw statement requires a single argument: a Throwable object. throws: Instead of trycatch block, if you want to catch exception in any method you can use throws clause with that method.

6. What are the advantages of URL-Rewriting over Cookies?

URL rewriting is another way to support anonymous session tracking. With URL rewriting, every local URL the user might click on is dynamically modified, or rewritten, to include extra information.

Advantage coparison

URL-Rewriting 1. URL Rewriting masks the dynamic URLs with static URLs. 2. Usability. 3. Security: It will make the site more secure as malicious user will not be able to get to know the structure of the application. 6. It works even if cookies are disabled

Cookies 2. Some sites or some malicious hackers can misuse cookies. 3. Cookies can be stolen via some cross site scripting; the Hacker exploits a vulnerable Web application and simply applies a JavaScript code to use your details for his own malicious purposes. 1. Because cookies are stored as plain text on to a computer that means that they can be edited and read by anyone unless and until the site thinks of your privacy and encrypts the data

6. If you delete cookies from your hard drive, it will be difficult for servers to trace your surfing or spending habits.

7. What is Web server? What are the various Web servers? A Web Server is a software program that delivers Web pages and other documents to browsers using the HTTP protocol.

When the Web server receives an HTTP request, it responds with a HTTP response, such as sending back an HTML page. Every Web server has an IP address and possibly a domain name. For example, if you enter the URL http://www.mniop.org/admission.html in your browser, this sends a request to the server whose domain name is mniop.org. The server then fetches the page named admission.html and sends it to your browser. A Web server may not itself support transactions or database connection pooling. It handles HTTP requests only. Common Web servers are: Apache Tomcat, Microsoft IIS, lighttpd, and Google GWS. Other type web servers include; Nginx web server, lighttpd, Jigsaw, Oracle Web Tier, Zeus web server, Klone http://www.webdevelopersnotes.com/hosting/list_of_web_servers.php3

8. What is Servlet? What are the features of 2.5 API? Explain.

9. What are the differences between sendRedirect and RequestDispatcher? 10. What are the ways of handling exception? Explain any one in detail. 11. What are Cookies? Explain with an example.

August 2011 Bachelor of Science in Information Technology (BScIT) Semester 4 BT0083 Server Side Programming - Theory 4 Credits
(Book ID: B1088)

Assignment Set 2 (60 Marks)

Answer all questions 1. What are the advantages of Client-Cert authentications? 2. What are the different types of Resultsets? 3. Explain Model-2 architecture of JSP. 4. What are the common errors in the process of translating the JSP? 5. Describe the theory behind accessing bean properties. 6. Compare BASIC authentications with HTTP Digest authentications.

10 x 6 = 60

7. What is a transaction? Explain the methods setAutoCommit() and rollback(). 8. Explain various Scripting elements of JSP. 9. What are hierarchical tag structures? Explain. 10. Explain the theory of referencing implicit objects with a suitable example.

Das könnte Ihnen auch gefallen