assign_ajp4
assign_ajp4
1) In the following statements identify the disadvantages 2) Servlet technology is used to create web application?
of CGI? A) True
A) If number of clients increases, it takes more time for B) False
sending response
B) For each request, it starts a process and Web server is
limited to start processes
C) It uses platform dependent language e.g. C, C++, perl
D) All mentioned above
3) In HTTP Request method Get request is secured 4) In the HTTP Request method which is non-idempotent?
because data is exposed in URL bar? A) GET
A) True B) POST
B) False C) BOTH A & B
D) None of the above
5) Give the examples of Application Server from the 6) Which packages represent interfaces and classes for servlet
following? API?
A) Apache A) javax.servlet
B) Tomcat B) javax.servlet.http
C) JBoss C) Both A & B
D) Weblogic D) None of the above
E) Both C & D
7) The web container maintains the life cycle of a servlet 8) The sendRedirect() method of HttpServletResponse
instance,give the lifecycle of a servlet? interface can be used to redirect response to another
A) Servlet class is loaded resource, it may be servlet, jsp or html file?
B) Servlet instance is created A) True
C) init,Service,destroy method is invoked B) False
D) All mentioned above
9) An object of Which is created by the web container at 10) An attribute in servlet is an object that can be set, get or
time of deploying the project? removed from one of the following scopes?
A) ServletConfig A) session scope
B) ServletContext B) request scope
C) Both A & B C) application scope
D) None of the above D) All mentioned above
11) How many techniques are used in Session Tracking? 12) Which methods are used to bind the objects on
A) 4 HttpSession instance and get the objects?
B) 3 A) setAttribute
C) 2 B) getAttribute
D) 5 C) Both A & B
D) None of the above
13) Which class provides stream to read binary data such 14) These methods doGet(),doPost(),doHead,
as image etc. from the request object? doDelete(),deTrace() are used in?
A) ServltInputStream A) Genereic Servlets
B) ServletOutputStream B) HttpServlets
C) Both A & B C) Both A & B
D) None of the above D) None of the above
15) Sessions is a part of the SessionTracking and it is for 16) In Session tracking which method is used in a bit of
maintaining the client state at server side? information that is sent by a web server to a browser and
A) True which can later be read back from that browser?
B) False A) HttpSession
B) URL rewriting
C) Cookies
D) Hidden form fields
17) Servlets handle multiple simultaneous requests by 18) Which of these ways used to communicate from an applet
using threads? to servlet?
A) True A) RMI Communication
B) False B) HTTP Communication
C) Socket Communication
D) All mentioned above
1
19) Web server is used for loading the init() method of 20) Which class can handle any type of request so it is
servlet? protocol-independent?
A) True A) GenericServlet
B) False B) HttpServlet
C) Both A & B
D) None of the above
21) Which of the following JSP variables are not
available within a JSP expression. Select the one correct
answer.
A) out
B) session
c) request
d) response
e) httpsession
f) page
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HttpLoginServlet extends HttpServlet {
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.println("<html><body>");
String uname = (String)request.getParameter("username");
String pwd = (String)request.getParameter("password");
int len =pwd.length();
if(uname.equals("System"))
{
2
}}
// Get writer.
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.print("<B>");