040010402- Web Application Development

040010402- Web Application Development
2014
Unit 1: Architecture
Que: 1 Answer the following question in short.
[1 mark each]
1. What do you mean by Web application?
2. Which are the core elements of any web application?
3. List out the types of application’s architecture.
4. List out the advantages of single tier architecture.
5. List out the disadvantages of two tier architecture.
6. How components are there in two tier architecture?
7. Into how many elements application process management is divided?
8. How many layers are there in three tier application?
9. List out the advantages of three tier application.
10. Which architecture requires clustering and disaster recovery?
11. In multi-tier architecture who is responsible for providing access to backend?
12. Why multi-tier applications are considered to be three-tier applications?
13. What is container?
14. How many types of containers are there?
15. Which container is responsible for spawning the EJB on demand?
16. What is the full form of EIS?
17. What is the full form of JNDI?
18. What is the responsibility of EJB container?
19. List out the containers are used at server side.
20. List out the containers are used at client side.
Que: 2 Answer the following question in brief.
[2-3 marks each]
1. List out the factor which must follow before deciding the Java EE application tier. Explain any two of
them in brief.
2. Write a brief note on Java EE single tier architecture.
3. Write a brief note on Java EE two tier architecture.
4. Write a brief note on Java EE three tier architecture.
5. Write down the function of Presentation layer, business layer, and data layer.
6. List out any two differences between presentation tier and business tier.
7. List out the tiers in which enterprise architecture is divided. Explain any one in brief.
8. Write a brief note on web client.
9. Write down any four task of web tier.
10. List out any five technologies that are use in web tier. Explain any one of them in brief.
11. List out the component of Enterprise Information System Tier.
12. List out the Java EE container type. Explain any one of them in brief.
13. What are the services provided by the container to a component?
14. Write a brief note on Enterprise JavaBean.
15. List out the Java EE technologies that are used in the business tier.
Que: 3 Answer the following question in details.
[4 marks each]
1. To process an input and output, list out the elements of Java enterprise application. Explain any one
of them in detail.
2. List out the type of Java EE architecture. Explain any one of them in detail.
3. Compare Single tier architecture with two tier architecture with an appropriate diagram, advantages
and disadvantages.
4. Compare two tier architecture with three tier architecture with an appropriate diagram, advantages
and disadvantages.
5. If the application will not grow over time, then which of the system architecture should choose by
the developer? Justify in detail.
6. To develop an initial electronic commerce site, and provide the cost benefit to customer, then which
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 1
040010402- Web Application Development
2014
of the system architecture should choose by the developer? Justify in detail.
7. 3- tier architecture is an evolution of 2-tier architecture - Justify.
8. List out the constitute layers of a 3 – tier architecture. Explain all of them in brief.
9. To develop a system called “stock trading system”, as a developer which of the system architecture
chooses by you? Justify in detail.
10. Write a detailed note on multi-tier architecture with an appropriate diagram.
11. Java EE architecture is an extension of the concept of multi-tier architecture - Justify.
12. Write a short note on Java EE architecture with an appropriate diagram.
13. Explain the basic core elements of Web applications.
14. Explain the factors needs to be considered before deciding the application architecture.
15. Explain Single tier architecture in detail with its advantages and disadvantage.
16. Write a note on Java EE containers in detail.
Que: 4 Select most appropriate answer from the given option.
[1 mark each]
1. What is true about web application?
a. It is a process
b. It is an application
c. It is an interface
d. None of the above
2. Which of the following is not core element of all application architecture?
a. Presentation element
b. Infrastructure Element
c. Business Logic
d. Storage
3. Which of the following is an advantage of single-tier architecture?
a. Scalability
b. Maintainability
c. Security
d. Performance
4. In which architecture network traffic is zero?
a. Single-Tier
b. Two-Tier
c. Three- Tier
d. Multi-Tier
5. Where two-tier architecture is used frequently?
a. Non-complex
b. Non-time critical
c. Information Processing System
d. All of the above
6. Which of the following is functionality of two-tier architecture?
a. Hardware Independent
b. Hardware lock-in
c. Database Management System
d. All of the above
7. Which of the following architecture hides the complexity of distributed processing from the user?
a. Single-Tier
b. Two-Tier
c. Three-Tier
d. None of the above
8. Which of the following application components provides an interface directly with databases?
a. Data Access Objects
b. DBMS
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 2
040010402- Web Application Development
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
2014
c. OLAP
d. OLTP
In which architecture object relational mapping is difficult?
a. Single-Tier
b. Two-Tier
c. Three-Tier
d. None of the above
Which of the following architecture is often used for department specific applications?
a. Single-Tier
b. Two-Tier
c. Three-Tier
d. Both (b) and (c)
Which of the following is an example of Presentation Tier of N-Tier architecture?
a. Firewall
b. User’s Machine
c. Interface
d. Rules
Which of the following comes under the middle layer of N-Tier architecture?
a. User Integration Tier
b. Data Access Tier
c. Infrastructure Tier
d. Data Tier
Which of the following provides the functionality of handling all data I/O?
a. Business Tier
b. User Interface Tier
c. Infrastructure Tier
d. Integration Tier
Which of the following provides a container that takes care of theses application services?
a. Web container
b. Client Container
c. Java EE server
d. EJB container
Which of the following is the only way to access the functionality of a component object?
a. Server
b. Container
c. Client
d. All of the above
Which of the following Container does not contains Java beans components?
a. Client
b. Web
c. EJB
d. None of the above
Which of the following in container works on client machine?
a. Web and EJB
b. Web and Java EE
c. Application Client and Web
d. Application Client and Applet
Which of the following container hosts web applications?
a. Java EE container
b. EJB container
c. Web container
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 3
040010402- Web Application Development
2014
d. All of the above
19. Which of the following container runs Java plugins?
a. Java EE container
b. EJB container
c. Application Client Container
d. Applet Container
20. All the ___________ data is kept at the application server ___________ data is kept at the web
server
a. Dynamic, static
b. Static, dynamic
c. Html, servlet
d. Servlet,html
21. Where the application components are first assembled?
a. Java EE Module
b. Client
c. Container
d. All of the above
Que 5: Fill in the blanks.
[1 mark each]
1. The ____________ element manages the storage and retrieval of data.
2. The capacity of an application to adapt to any new hardware environment is known as __________.
3. The ability of an application to provide to the increase demand from is client is known as ________.
4. The ability of an application to incrementally add features from time to time to improve the
performance and provide the better functionality to the client is known as ____________.
5. The ability of an application to respond to a client request in the minimum time is known as
_____________.
6. The ____________ tier architecture is simplest and least expensive.
7. In the context of Java EE 2-tier architecture, the _____________ is always physically located in the
users’ desktop.
8. The _____________ has to service multiple client requests to store or retrieve data.
9. The _____________ tier the responsible for providing access to backend resources including
powerful relational database and external system.
10. The middle tier is application code, which a user invokes via the ________________ layer.
11. The application is actually a collection of ______________ code modules that communicate through
standardized, abstract interfaces.
12. ________________layer of N-Tier architecture defines what user interface displays and how a user’s
requests are handled.
13. __________________layer of N-Tier architecture contains business rules and business data
manipulation.
14. __________________ layer of N-tier architecture provides additional functionality which required by
the application components.
15. ________________does not demand that each of the application layer run on a separate machine.
16. ________________architecture is the extension of the concept of multi-tier architecture.
17. The Java EE server is the runtime portion of a __________________ product.
Que 6: True False
[1 mark each]
1. User interface is also known as presentation element.
2. Application logic helps in implementing the operation to be performed on the data input.
3. Data management element manages the storage and retrieval of data.
4. The ability of an application to maintain the integrity of data is known as security.
5. The ability of an application to respond to bug fixes with the minimum utilization of resources in
terms of people, time and technology is known as maintainability.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 4
040010402- Web Application Development
2014
6. In single tier architecture all the services provided by the application are exists on same physical
machine.
7. In the context of Java EE 2-tier architecture, the database management services are always physically
located on server.
8. 3-tier architecture is most expensive, but most secure and scalable.
9. In 3 – tier architecture additional business layer can be added and application can be cloned across
multiple computers.
10. Multi-tier architecture does not prevent the use of the two or three-tiered architecture.
11. Integration layer is merely reusable component.
12. The layer approach makes for a more scalable enterprise application.
13. In Java EE, application logic is divided into components according to function.
14. The separation of application logic from the user interface adds enormous flexibility to the design of
an application.
15. Multiple user interfaces can be built, deployed or destroyed without ever changing the application’s
business logic.
16. The third tier contains the business data required by the application.
17. The advantages of three tier architecture extend beyond the life cycle of a single application.
18. An example of N tier architecture is LAN.
19. Integration tier in N tier architecture contains data business rules or data manipulation or
transformation logic.
20. Java EE server contains Web container and Application Client container.
21. A Java EE container that hosts web applications is EJB container.
22. J2EE consist of four tiers.
23. A request is typically passed from one tier to another before the request is full fill.
Unit 2: Servlet Programming
Que: 1 Answer the following question in short.
1. What are Servlet?
2. Which protocol is used to implement Servlet?
3. Name Servlet life cycle methods.
4. Which package is used to define Servlet API?
5. Which method is used to initialize Servlet?
6. How would you create deadlock on your servlet?
7. How to retrieve information of Form sent by client?
8. What is the role of Servlet?
9. Write down any one role of deployment descriptor.
10. What you need to set before transmitting the actual document?
11. Which class you need to inherit while creating servlet file?
12. Where to place .java file in tomcat server?
13. Write down the use of HttpServletRequest argument in servlet.
14. Write down the use of HttpServletResponse argument in servlet.
15. Which method of HttpServletResponse is to determine the size of buffer?
16. Which class contains setContentType() method?
17. Which method is invoked when the servlet is first created?
18. Which method is call after each user request?
19. Which method of servlet life cycle is used for one time initializations?
20. Which file contains the servlet mapping information?
21. What is the purpose of ServletConfig?
22. Write down the use of javax.servlet.ServletConfig of class.
23. What are the methods available in ServletConfig?
24. Which method of HttpServletResponse encodes the specified URL?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
[1 mark each]
Page 5
040010402- Web Application Development
2014
25. What is ServletContext?
26. How the servlet is loaded?
27. How the servlet is unloaded?
28. What is Servlet interface?
29. Can servlet have a constructor?
30. Should I override the service() method?
Que: 2 Answer the following question in brief.
[2-3 marks each]
1. What is use of Servlet?
2. What is difference between doGet() and doPost()?
3. When to use doGet() and doPost()?
4. Write down the class hierarchy for any servlet file.
5. Write down the arguments which need to be passed by the doGet or doPost method of servlet?
6. Which information is passed with HttpServletRequest?
7. Which information is passed with HttpServletResponse?
8. Which environment variable is to be set when you are running any servlet via command prompt?
9. Write down any two differences between PATH and CLASSPATH.
10. Write down steps to define package in servlet.
11. Can we change the url pattern for any servlet?How?
12. Write down any three ways for storing retrieving attributes from servlet file.
13. What are the different methods for requesting attribute for input in servlet?
14. List out the methods of ServletRequest?
15. How do we write expressions in JSP?
16. When do we use servlet & in which scenario we will prefer creating JSP pages?
17. What is single thread model?
18. What are the purposes of implementing single thread model in servlet?
19. What is the use of Web.xml file?
20. How to initialize for initialization of parameter of servlet into web.xml file?
21. How to handle error page into servlet using configuration file?
22. What is the use of servletRequest and ServletResponse interface?
23. What is the use of HttpRequest and HttpResponse?
24. List out available methods in HttpServletRequest and HttpServletResponse.
25. Write down any two advantages of Servlet over CGI.
26. Write down any two differences between HttpServlet and GenericServlet.
27. Write down any two differences between ServletContext and ServletConfig.
28. What are the phases of the servlet life cycle?
29. Why do we need a constructor in a servlet if we use the init method?
30. Why HttpServlet is declared abstract?
31. What are the types of protocols supported by HttpServlet ?
32. When to use doGet() and when doPost()?
33. How do I support both GET and POST from the same Servlet?
34. What is a servlet context object?
Que: 3 Answer the following question in details.
[4 marks each]
1. What is the importance of deployment descriptor in servlet? Explain with suitable example.
2. What is servlet? Explain the life cycle of Servlet?
3. What is HttpServlet?Explain doGet() and doPost() method used in that.
4. Which is the superclass of all servlet?How will you create a servlet?Write a minimum code to display
“Hello World”.
5. Which is the default http method in http servlet?Explain with example.
6. Explain send redirect method .When it is used? Explain with an appropriate example.
7. In which conditions we have to use the ServletContext? List out and explain the methods of
ServletContext.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 6
040010402- Web Application Development
2014
8.
9.
10.
11.
12.
13.
14.
What is servlet chaining?Write a code that will pass an argument from one servlet to another servlet.
Explain how to set response headers from servlets.
Explain how to access the standard CGI variables.
How to do deployment of directories?
Write a note on role of web middleware.
Write a note on basic servlet structure.
What is the difference between ServletResponse sendRedirect() and RequestDispatcher forward()
method?
15. Do we need to override service() method in Servlet? Justify your answer.
Que: 4 Select most appropriate answer from the given option.
[1 mark each]
1. Servlet is _______________ technology.
A. Client side
B. Server side
C. Host
D. Virtual
2. In which file do we define a servlet mapping?
a. Web.xml
b. Servlet.mapping
c. Servlet.xml
d. Simple.java
3. Given the following servlet mapping definition for the web application named 'secureapp' –
<servlet>
<servlet-name>ProcessLoginData</servlet-name>
<servlet-class>DoLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProcessLoginData</servlet-name>
<url-pattern>do/Login</url-pattern>
</servlet-mapping>
Which of the following URLs will correctly request the Servlet?
a. http://www.mywebapp.com/secureapp/Login?name="bob"
b. http://www.mywebapp.com/Login?name="bob"
c. http://www.mywebapp.com/secureapp/doLogin?name="bob"
d. http://www.mywebapp.com/secureapp/do/Login?name="bob"
4. A servlet class that is used in a web application extends the class______________
a. HttpServlet class
b. Generic Servlet
c. MyServlet
d. HttpServletRequest
5. When HTML page request a servlet with the HTTP Post method,the ___________methods of the
servelt class will be call.
a. doPost()
b. doGet()
c. doPut()
d. doDelete()
6. Which of the following statements correctly define the use of servlet over CGI?
a. Servlet provide a way to generate dynamic documents that is both easier to write and faster
to run.
b. Servlet also address the problem of doing server-side programming with platform- specific
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 7
040010402- Web Application Development
2014
APIs
c. They are developed with the Java Servlet API, a standard Java extension
d. They have slower response
7. The following is the sequence of the life cycle of the servlets.
i.Init() ii. Destroy() iii. Service()
a. 1,2,3
b. 1,3,2
c. 2,3,1
d. 1,3,2
8. Which of the following statement is true about the GenericServlet?
a. GenericServlet is for servlets that might not use HTTP, like for instance FTP service.
b. As of only Http is implemented completely in GenericServlet.
c. The GenericServlet has a service() method that gets called when a client request is made.
d. GenericServlet is called by both incoming requests and the HTTP requests are given to the
servlet as they are.
9. Which of the following statements is true about Servlet chaining?
a. It is the process of chaining the output of one Servlet to the another
b. Need to do special configuration in the Java Web servers for this process to run
c. This concept has been removed from the standard application for servlets
d. None of the above
10. Calling of which of the following method causes unpredictable results in the Servlet.
a. doPost()
b. doGet()
c. System.out.println()
d. System.exit(0)
11. Which of the following statement is true about the ServletInterface?
a. The central abstraction in the Servlet API is the Servlet interface.
b. All Servlet implement this interface, either directly or, more commonly, by extending a class
that implements it such as HttpServlet.Servlets > Generic Servlet > HttpServlet > MyServlet
c. The Servlet interface declares, but does not implement, methods that manage the Servlet
and its communications with clients
d. Servlet writers dont provide some or all of these methods when developing a Servlet
12. In which file do we define a servlet mapping?
a. Web.xml
b. Servlet.mappings
c. Servlet.xml
d. None of the above
13. Which packages in the java provide the writing of the Servlet?
a. Javax
b. Java
c. Java.io
d. java.lang
14. If the data being submitted is sensitive, then it's always preferred to use _____________
a. doGet
b. doPost
c. service
d. one of the above
15. Which of the options correctly defines the methods in the HttpServelet class are?
a. protected void doGet (HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
b. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 8
040010402- Web Application Development
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
2014
ServletException, IOException
c. protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
d. protected void service(HttpServletResponse response, HttpServletRequest request) throws
ServletException, IOException
The major difference between servlet and CGI is
a. Servlet are thread based and CGI are process based
b. Servlet executes slower compare to CGI
c. Servlet has no platform specific API, where CGI has
d. All of the above
What is the limit of data to be passed from HTML when doGet() method is used?
a. 4k
b. 2k
c. 8k
d. 1k
Which method is used to specify before any lines that uses the PrintWriter?
a. setPageType()
b. setContextType()
c. setContentType()
d. setResponseType()
To get the servlet environment information
a. ServletConfig object is used
b. ServletException object is used
c. ServletContext object is used
d. ServletContainer object is used
A deployment descriptor describes
a. We component response settings
b. Web component settings
c. Web settings
d. All of the above
The values of <servlet-name> and <servlet-class> in web.xml file
a. Must be same
b. Must not be same
c. May be same
d. None of the above
Servlet mapping defines
a. An association between a URL pattern and a servlet
b. An association between a URL pattern and a request page
c. An association between a URL pattern and a response page
d. All of the above
The life cycle of servlet is managed by
a. Servletcontext
b. ServletContainer
c. Supporting protocol(http)
d. All of the above
The init parameter name and value pairs that defined in web.xml are handled by
a. ServletConfig object
b. ServletContext object
c. ServletRequest object
d. ServletResponse object
How many ServletContext objects are available for an entire web application?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 9
040010402- Web Application Development
2014
a. One each per Servlet
b. One each per request
c. One each per response
d. Only one
26. In the properties files _________ defines global Servlet settings and list of servlets in the system.
a. Servlet.properties
b. Page.properties
c. Session.properties
d. None of the above
27. What are the mechanisms available in ServletContextListener interface?
a. ContextInit(),ContextService(),ContextDestroyed()
b. Contextinitialized(),Contextdestroyed()
c. Contextinitialized(),contextservice(),contextdestroyed()
d. None of the above
28. Dynamic interception of requests and responses totransform the information is done by
a. Servlet Filter
b. Servlet Context
c. Servlet Container
d. Servlet Config
29. Arguments can be passed to the Servlet in the following ways
a. Using name/value pairs in the URL
b. Providing the details in the conf/web.xml files
c. Using param name construct.
d. None of the above
30. The tasks –authentication –blocking of requests, data compression, logging and auditing are
performed by
a. Servlet Filter
b. Servlet Context
c. Servlet Container
d. Servlet Config
Que 5: Fill in the blanks.
[1 mark each]
1. The _________interface provides information to servlets regarding the environment in which they are
running.
2. ________________ is used to call other Servlet or JSP from the current Servlet
3. _______________________ Classes HttpServlet and GenericServlet implement the interface.
4. Class HttpServlet defines the methods and to respond to get and post requests from a client is
___________ and _______________.
5. ____________________ HttpServletResponse() method obtains a character-based output stream that
enables text data to be sent to the client.
6. The form attribute specifies the server-side form handler, i.e., the program that handles the request is
_____________.
7. __________ is the well-known host name that refers to your own computer.
8. Headers are set by the setHeader() method of ______________________ class.
9. _____________ instance of each servlet gets created, with each user request.
10. _______________ method of servlet life cycle is used to put one-time setup code.
11. The service method of servlet checks the ________________ request type.
12. The init method performs ______________ varieties of initializations.
13. In URL, the part after question mark is known as ______________.
14. getParameterNames() method returns the list in ____________________.
15. If there are no parameters in the current request, getParameterNames() returns ______________.
16. _______________method returns the main request method.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 10
040010402- Web Application Development
2014
17. _______________method returns the form data.
18. _____________method returns the third part of the request line.
19. _______________header is used by clients to identify themselves when accessing password protected
web pages.
20. A status code 403 of HTTP means ___________________.
21. _______________ method sets the Location header as well as setting the status code to 302.
Que 6: True False
[1 mark each]
1. Constructor can be used instead of init method to initialize a servlet.
2. An HTTP Servlet handles client requests through its service() method.
3. Servlets usually are used on the client side of a networking application.
4. Servlet methods are executed by the servlet container.
5. The two most common HTTP requests are get and put.
6. The well-known port number for Web requests is 55.
7. Service method does not give any automatic support for HEAD, OPTION and TRACE requests.
8. Form data can be attached to the end of the URL after equation symbol.
9. A null value is returned if the parameter exists but has no value.
10. The values supplied to getParameter and getParameterValues are not case sensitive.
11. The return value of getParameterValues is a one-element array when the parameter has only a
single value.
12. An alternative to getParameterNames is getParameterMap.
13. All request headers are optional in HTTP 1.0.
14. The getContentLength() method returns the value of Content-Type header.
15. The getRequest() method returns the part of the URL.
16. When you want to set an arbitrary status code, setStatus() method of HttpServletRequest is used.
17. In HTTP 1.1 status code 500-599 signifies an error by the client.
18. In HTTP 1.1, Allow header specifies the request methods that the server supports.
19. HTTP allows multiple occurrences of the same header name.
20. Accept-Encoding header is used by the clients to identify themselves when accessing passwordprotected web pages.
Unit 3: Session Management
Que: 1 Answer the following question in short.
[1 mark each]
1. What is Session attribute?
2. What do you mean by Session object?
3. What is the use of HttpSession?
4. What is a cookie?
5. How to create cookie?
6. Write a location, where cookie is stored.
7. Which method is used to get all parameter values in the current request?
8. What is the return value, if the parameter exists but has no value?
9. What does the getparamentervalues() return for the nonexistent parameter names?
10. What does getHeader() method of HttpServletRequest returns?
11. Which method of HttpServeltRequest returns the contents of the Cookie?
12. Which request header specifies the client’s preferred languages in case the servlet can produce
results in more than one language?
13. Which header is used by clients to identify themselves when accessing password-protected Web
pages?
14. Which header is applicable only to POST requests?
15. Which method is used to redirects users to browser specific pages?
16. Which protocol is stateless?
17. What is URL rewriting?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 11
040010402- Web Application Development
2014
18. Which method of HttpSession is call before you send any document content to the client?
19. What's the use of the servlet wrapper classes?
20. What is the directory structure of a WAR file?
21. What is a deployment descriptor?
22. What does getAttributeNames() method of Session returns?
23. Which method returns the unique identifier generated for each session?
24. Which method invalidates the session and unbinds all objects associated with it?
Que: 2 Answer the following question in brief.
[2-3 marks each]
1. Explain with an example to set values in Cookies.
2. Explain with an example to create long live Cookies.
3. Write a snipped to delete the session data.
4. What is the difference between the getRequestDispatcher(String path) method of
javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?
5. Write down the snipped to get parameter values, if the same parameter name appear in the form
data more than once?
6. List out the different type of session tracking.
7. Which three conditions to need to check while examining request parameters?
8. List out some methods of HttpServletRequest.
9. List out the ways for session tracking.
10. List out any one difference between the include() and forward() methods with an appropriate
example
11. List out any one difference between forward() and sendRedirect() methods with an approriate
example.
12. Write down the snipped to invalidate all sessions associated with the client.
13. How to store and retrieve values from a session objects?
14. In Servlet, how to redirect on specific page? Give an example.
15. What is the <load-on-startup> element?
Que: 3 Answer the following question in details.
[4 marks each]
1. List out any one difference between Session, cookies, and persistent cookie.
2. Define cookies. How to create and get the cookies using Httpservlet? Explain with an appropriate
example.
3. Define session. How to set and get the session using Httpservlet? Explain with an appropriate
example.
4. Write down the advantages of cookies.
5. Write down the advantages of Session over cookies.
6. Write down the disadvantages of cookies with an appropriate example.
7. Write down the basic steps to delete the cookies from your browser.
8. How would you send the cookies to the client?
9. How do I use cookies to store session state on client?
10. Explain Session tracking API with an appropriate example.
11. Write down the need for Session tracking with any one scenario.
12. Explain the different ways to discard the Session data.
13. Compare Browser Session vs. Server Session.
14. Write down the Servlet code that shows per-client access count.
15. Write down the scenarios in your project, where you shall use session tracking technique.
16. How would you accumulate user data? Explain with an example.
Que: 4 Select most appropriate answer from the given option.
[1 mark each]
1. Which of the following are the session tracking techniques?
a. URL rewriting,using session object,using response object, using hidden fields
b. URL rewriting , using session object,using cookies, using hidden fields
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 12
040010402- Web Application Development
2.
3.
4.
5.
6.
7.
8.
9.
10.
2014
c. URL rewriting,using session object,using response object, using cookies
d. URL rewriting,using session object,using response object, using request object
RequestDispatcher object is used
a. To include to other resources
b. To include an image
c. To include an xml object
d. To include an emailing response
The getSession() method with ‘true’ as its parameter [ getSession(true)] it will return the appropriate
session object when
a. The session is completed
b. The session object is passed to another method
c. The session does not exists
d. The session is existing
The method forward(request,response) will
a. Return back to the same method from where the forward is invoked
b. Not return back to the same method from where the forward is invoked and the web page
navigations continues
c. Both A and B are correct
d. None of the above
A servlet maintain session in
a. Servlet context
b. Servlet container
c. Servlet request heap
d. Servlet response heap
The include() method of RequestDispatcher
a. Sends a request to another resource like servlet,jsp or html
b. Includes resource of file like servlet, jsp, or html
c. Appends the request and response objects to the current servlet
d. None of the above
Which of the following statements are true?
1.
cookie.setMaxAge(0) – delete the cookie
2.
cookie.setMaxAge(1) –the cookie will live before it expires
3.
cookie.setMaxAge(-1) – the cookie will not be stored beyond this session.
a. i only
b. ii and iii only
c. i, ii only
d. i,ii,iii
The maximum age of the cookie can be set by
a. cookie.setMaxAge(int seconds)
b. cookie.setMaxAge(float seconds)
c. cookie.setAgeMax (float seconds)
d. cookie.setAgeMax (int seconds)
The browsers are only required to accept________ cookies per site, __________ total per user , and
they can limit each cookie's size to
a. 20, 300, 4096 bytes (4K).
b. 300,20, 4096 bytes (4K).
c. 30,200, 4096 bytes (4K).
d. 200,39, 4096 bytes (4K).
These ______________listeners are notified when attributes are added to, removed from, or
replaced in any session.
a. Session Attribute
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 13
040010402- Web Application Development
31.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
2014
b. Session Listeners
c. Servlet context attribute
d. Servlet context listeners
The ________ listeners are notified when session objects are created, invalidated, or timed out.
a. Session Attribute
b. Session Listeners
c. Servlet context attribute
d. Servlet context listeners
The______________ listeners are notified when attributes are added to, removed from, or replaced
in the Servlet context.
a. Session Attribute
b. Session Listeners
c. Servlet context attribute
d. Servlet context listeners
The ________________________ when added to the user session tells us that the session timed out.
a. SessionTotalTimeOutIndicator
b. SessionTotalTimedoutIndicator
c. SessionTimeoutIndicator
d. SessionTimedoutIndicator
Which of the following cookies are not deleted when the browser is closed?
a. Session cookies
b. Transient cookies
c. Permanent Cookies
d. All of the above
Which of the following is the amount of time, which a client takes while navigating through a site?
a. URL rewriting
b. Session
c. Cookies
d. None
Which of the following interface is used for session handling?
a. Java.servlet.http.http.HttpSession
b. Javax.servelt.http.HttpSession
c. Java.servelt.http.HttpSession
d. Javax.servelt.HttpSession
Which of the following do not require parsing of the requested URL or an HTML document?
a. Cookie
b. Session
b. Hidden Fields
d. URL rewriting
Which of the following provides a means to implement anonymous session tracking?
a. Cookie
b. Session
b. Hidden Fields
d. URL rewriting
Which of the following method must be called at least once before any output is written to the
response to ensure the session properly maintained?
a. response.setsession()
b. response.getsession()
b. request.getsession()
d. request.setsession()
Which of the following extracts a previously stored value from a session object?
a. public object getattribute(string name)
b. public enumeration getattribute(string name)
c. public string getattribute(string name)
d. public void getattribute(string name)
What is the return value of getMaxInteractiveInterval() method for the session that never expire?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 14
040010402- Web Application Development
2014
a. 1
b. 0
c. -1
d. None
Que 5: Fill in the blanks.
[1 mark each]
1. The maximum length of the session Id(length identifier) is ___________.
2. The two types of cookies in java are Permanent cookie and _________ cookie.
3. Sharing of session data across multiple load balanaced web servers is called _____________ .
4. The ______________ method yields an array of Cookie objects.
5. To specify that a cookie apply to all URLs on your site, use ______________.
6. The servlet program run at the web server generates a _______________.
7. A cookie is sent as ___________of the response object to the client.
8. The cookie name and value is extracted using _______________ and ___________ methods of the
cookie object.
9. A________________can be considered as a series of related interactions between a single client and
the server that take place over a period of time.
10. A ___________ is sent in a cookie that is returned by the visitors Web browser with each request.
11. The servlet API’s , ________________class provides developers all that is required to track sessions
via servlet code spec.
32. ______________ can be done in static documents to contain the required session information.
12. _________________is the mechanism that servlets use to maintain state series requests from the
same user across some period of time.
13. The ______________ method returns the unique SESSION ID assigned to the current session.
14. The _________________________ method sets the maximum number of seconds that a session is
guaranteed to be valid without a request from the client.
15. The ______________________method returns the maximum amount of time in seconds that a
session is guaranteed to be valid without a request from the client.
17. The ____________ method of Httpsession, maintains only references to an attribute.
18. _____________________ method of HtppSession needs to be called whenever an object references
changes.
19. The ______________ method returns a list of all attributes names bound to the current session.
20. The getAttribute() method returns ____________, if no object is found bound to the name.
Que 6: True False
[1 mark each]
1. There is a limit to the max amount of data that can be stored in the session object.
2. A cookie contains more than simply a name and a value.
3. Permanent cookies can be used to identify individual users.
4. Session cookies are automatically deleted when the browser’s closed down.
5. The getCookies() method will returns a single element array containg null value, if no cookies are
available.
6. If the session object is invalidated can it be again regained or refreshed
7. From the current Browser window, if we open a new Window, then it referred to as Multiple
Windows. Are Sessions properties are maintained across all these windows, even though they are
operating in multiple windows?
8. HttpSession.setMaxInactiveInterval() can manage the inactivity lease period on a per-session basis.
9. While using request.getRequestDispatcher(path) we need to give the absolute path of the object
10. When you createna Cookie object, you must call setMaxAge before sending the cookie to the
client.
11. A session does not works when a clienthas disabled cookies in their browser.
12. The duration of an HTTP session is configurable on the Web server.
13. Automatically expiring sessions after a period of inactivity ensures that web server resources are
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 15
040010402- Web Application Development
2014
bound by old sessions.
14. An explicit log out immediately expires the session.
15. Sessions are lost if one or more servlets in an application do not call the encodeURL() or
encodedRedirectURL() methods.
16. HttpSession object has a built-in data structure that allows storing any number of keys and
associated values.
17. The getLastAccessedTime() method returns the most recent time that a visitor with the last session
accessed the server.
18. The last access time is the value the servlet engine uses to determine when the session has timed
out.
19. Every client of a site is associated with a javax.servlet.HttpSession object that Servlets can use to
store or retrieve information about that client.
20. In cookies, either relative or absolute URLs can be used by the web site without losing state.
Unit 4: JSP Programming
Que: 1 Answer the following question in short.
[1 mark each]
1. What is the full form JSP?
2. What do you mean by JSP?
3. What is JSP scriptlet?
4. What is JSP directive?
5. Which of the basic ways of using JSP technology?
6. Where do you declare methods in JSP?
7. Where do you use exception implicit object in JSP?
8. In which instances we will use the page scope?
9. What is the purpose of <jsp:usebean>?
10. Which element must appear before the <isp:setProperty> element?
11. What do you mean by Java beans?
12. Define comment tag in JSP.
13. Define Declaration statement tags in JSP.
14. What is the use of expression tag in JSP?
15. What is the use of scripting tag in JSP?
16. Define Scriptlets in JSP.
17. Define declaration in JSP.
Que: 2 Answer the following question in brief.
[2-3 marks each]
1. List out any three needs of JSP.
2. Explain with an example to write comments in JSP.
3. Explain with an example to write any expression in JSP.
4. List out JSP scripting elements.
5. How to insert values directly into the output?
6. List out an implicit objects of JSP.
7. Write down XML syntax for scriptlets.
8. List out the disadvantages of JSP.
9. List out any four difference between servlet and JSP.
10. List out the types of JSP directives. Explain any one of them in brief.
11. List out the purpose of JSP directives.
12. List out the ways of commenting the code specification in JSP.
13. List out the attributes available for page directives.
14. If we declare the page isThreadSafe=”false” then how the page will act?
15. What is the difference between _ispInit() and jspInit()?
16. What is the difference between jsp and servlet life cycles?
17. When we deploy an application into a server, to which servlets these JSP will convert into?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 16
040010402- Web Application Development
2014
18. What is the difference between HttpSession and application session?
19. Write down snipped to disable browser “Back” and “Forward” button from a JSP page?
20. Can we use main method inside JSP?Why?
21. How do we create a HttpSession that never times out?
22. How to maintain values inside form field while uploading image using jsp?
23. What is the difference between servletcontext and pagecontext?
24. List out the four scopes of jsp.
25. What is the difference between include directives and <jsp:include>?
26. Write down steps to load a java bean in JSP.
27. How to set the properties of bean ? Give example.
28. How to access the properties of the beans in JSP?
29. When param attribute of <jsp:setProperty> element is used?
Que: 3 Answer the following question in details.
[4 marks each]
1. How to write method and control statements and loop in JSP? Explain with an appropriate example.
2. Define cookie. How to create and get the cookie using JSP? Explain with an appropriate example.
3. Compare the JSP expressions, scriptlets and declaration with an appropriate example.
4. Explain similarity as well as differences between JSP and servlet. Give situations where, servlet is
preferred over JSP.
5. What are implicit objects available to the JSP Page? Explain any two.
16. What is the use of ResultSet in JDBC? Write a JDBC code for view list of records from a table using
parameterized query.
17. Explain different types of Statement in JDBC with their purpose.
18. What is the use of PreparedStatement in JDBC? List out various methods of PreparedStatement and
explain with suitable example.
19. How the transaction is carried out using JDBC API? Explain with example.
20. Write a note on JDBC driver type.
21. Write a note on JDBC process.
22. What is the callable statement? Explain with an appropriate example
23. How to read the result set using J2EE component.
24. List out the most commonly used metadata with brief explanation.
25. Write a code to show the use of ResultSetMetaData class.
Que: 4 Select most appropriate answer from the given option.
[1 mark each]
1. The difference between Servlets and JSP is the ................
a. translation
b. compilation
c. syntax
d. Both A and B
2. Arrange the lifecycle phases of JSP in correct order
1. Page translation: -page is parsed, and a java file which is a Servlet is created.
2. Page compilation: page is compiled into a class file
3. Page loading : This class file is loaded.
4. Create an instance :- Instance of Servlet is created
5. jspInit() method is called
6. _jspService is called to handle service calls
7. _jspDestroy is called to destroy it when the Servlet is not required.
a. 1,2,3,4,5,6,7
b. 1,4,3,2,5,6,7
c. 3,2,1,4,5,6,7
d. 4,5,3,6,2,7,1
3. Which of the following statements is true about the scope of ‘application’ in JSP?
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 17
040010402- Web Application Development
4.
5.
6.
7.
8.
9.
2014
a. Objects with application scope are accessible from pages processing requests that are in the
same application as they one in which they were created
b. All references to the object shall be released when the runtime environment reclaims the
Servlet-Context
c. Objects with application scope can be defined (and reached) from pages that are not sessionaware
d. References to objects with application scope are stored in the application object associated with
a page activation
Which of the following statements is true regarding the scope of ‘request’ in JSP?
a. Objects with request scope are accessible from pages processing the same request where they
were created.
b. All references to the object shall be released after the request is processed; in particular, if the
request is forwarded to a resource in the same runtime, the object is still reachable.
c. References to objects with request scope are stored in the request object.
d. All of the above
The JspPage interface defines the __________ and ____ method which the page writer can use in their
pages and are invoked in much the same manner as the ____ and _____ methods of a servlet.
a. jspInit(), jspDestroy(), init() , destroy()
b. init(),jspDestroy(),jspInit(),destroy()
c. destroy(),jspDestroy(),jspInit(),init()
d. init(),destroy(),jspInit(), jspDestroy()
The session tracking in the JSP can be done by
1. URL rewriting
2. Cookies
3. User-Authorization
4. Hidden Files
a. 1,3,4 only
b. 2,3,4 only
c. 1,2,4 only
d. 1,2,3,4
Which of the following are the implicit objects in JSP
1. Application, out
2. config, exception
3. page, pageContext
4. request, response, session
a. 1,2
b. 2,3
c. 2,3,4
d. 1,2,3,4
Under JSP 1.0 , the implicit object which can be used for reference is “this”. It is used to refer to the
a. Servlet generated by the JSP page
b. Servlet called by the jsp page
c. Calling the previous JSP page
d. None of the above
Which of the following correctly defines JSP technology
a. JSP page is a text based document that describes how to process a request to create a
response.
b. JSP page is a text based document that describes how to process a to response create a
request.
c. JSP page is a xml based document that describes how to process a request to create a
response.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 18
040010402- Web Application Development
2014
d. JSP page is a xml based document that describes how to process a to response create a
request.
10. Java Server Pages technology commonly called JSP technology offers the following advantages
11.
12.
13.
14.
15.
16.
17.
18.
a. Separation of dynamic and static content.
b. Support for scripting and tags
c. Reuse of components and tags.
e. All of the above
Following methods can be overridden in the JSP page.
a. jspDestroy()
b. jspInit()
c. _jspService()
d. getParameter()
Which codeline must be set before any of the lines that use the PrintWriter?
a. setContentWriter()
b. setWriter()
c. setPrintType()
d. setContentType()
Implementing the tag <%@ page isThreadSafe="false" % > implements the SingleThreadModel interface
making the Jsp
a. Content safe
b. Synchronised
c. Thread Safe
d. None of the above
Which of the tag contains a code fragment valid in the page scripting language?
a. <%code fragment %>
b. <%= expression %>
c. <%!Declaration %>
d. <%--comment -- %>
Which of the tag is used to show the comments in the JSP page?
a. <% code fragment %>
b. <%= expression %>
c. <%!Declaration %>
d. <%--comment -- %>
Java Server Pages specification does not includes
a.Script language declarations, scriplets and expressions.
b.JSP standard actions.
c. JSP standard directives
d.A portable tag extension mechanism
Choose the statement that best describes the relationship between JSP and servlets?
a. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime
usage.
b. Servlets and JSP are competing technologies for handling web requests.Servlets are being
superseded by JSP, which is preferred. The two technologies are not useful in combination.
c. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage
d. JSP and servlets are unrelated technologies
What is a benefit of using JavaBeans to separate business logic from presentation markup within the JSP
environment?
a. It allows the JSP to access middleware
b. It provides a dynamic markup environment, such that JavaBeans are integrated
seamlessly with the template presentation content, in order to create the dynamic
display for the client.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 19
040010402- Web Application Development
19.
20.
21.
22.
23.
2014
c. It provides the developer wit full access to the Java 2 Platform Enterprise Edition(J2EE),
which is unavailable from outside the JavaBean environment
d. None of the above
What alternatives exist to embedding Java code directly within the HTML markup of your JSP page?
a. Moving the code into your session manager
b. Moving the code into scriptlets
c. Moving the code into JavaBeans and Servlets
d. Moving the code into a transaction manager
Choose the statement that best described how to connect JSP pages and Enterprise JavaBeans(EJBs):
a. Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean
b. Lookup and use the EJBs from a separate business delegate. The JavaBeans that work
with JSP pages are clients tp these business delegates and know nothing about EJB
specifies
c. Lookup the EJBs from within a servlet, delegating usage to specific JSP pages.
d. Lookup and use EJBs from within a JSP page, but only as remote references
Are custom tags available in JSp 1.0? If not, how else might you implement iteration from within a JSP?
a. Yes, but the tags available relate to database access.
b. Yes, but custom tags will not help developers create tags for use in iterating over a
collection
c. No, To iterate over a collection of valus, one must use scriptlet code.
d. No, but there is a standard tag that may be used.
What is the initial contact point for handling a web request in a Page-centric architecture?
a. A JSP page
b. A JavaBean
c. A servlet
d. A session manager
What is the difference between doing an include or a forward with a RequestDispatcher?
a. The two methods provide the same functionality, but with different levels of
persistence.
b. The forward method is deprecated as of JSP1.1 and the include method should be used
in order to substitute portions of a dynamic display at runtime.
c. The include method transfers control to a dynamic resource, while the forward method
allows for dynamic substitution of another JSP pages output, returning control to the
calling resource.
d. The forward method transfers control to the designated resource, while the include
method invokes the designated resource, substitutes its output dynamically in the
display, and returns control to the calling page.
24. Which of the following can the JSP include action include output from?
a. Another JSP
b. Servlet
c. Plain text file
d. All of the above
25. The <jsp:include/> action can pass parameters to the page which it is including. How does this second
page obtain the value of these parameter
a. Using the <jsp:readParam/> action
b. Using the <jsp:getParam/> action
c. Use the request.getParameter() method
26. Which of the following is not a standard method called as part of the JSP life cycle?
a. Applet
b. Servlet
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 20
040010402- Web Application Development
2014
c. Application
d. Mailet
Que 5: Fill in the blanks.
[1 mark each]
1. We can restrict the calling of the errorPage in the JSP by setting the value true for the
_____________ param in the ErrorPage attribute of the Page Directory.
2. A JSP page is a text document that contains ________________ and ______________ types o text.
3. JSP uses _______________and _______________ for the HTTP protocol.
4. ____________are nothing but holders of Java code spec in an HTML page.
5. _____________________- identify a particular block of code which otherwise is in pure HTML
language.
6. ____________ is every thing in the web page that is not a JSP element.
7. JSP has no dependency on __________.
8. The __________directive allows importing classes,customizing the servlet superclass.
9. The __________ directive allows including files at the time the JSP page is translated into a
Servlet.
10. There are _______________restrictions on the number of include directives that may appear in a
single JSP file.
11. JSP expressions and scriptlets deal only with code inside the __________________ method.
12. The ______________attribute is the only page attribute that is allowed to appear multiple times
within the same document.
13. The _______________attribute sets the Content-Type response header, indicating the MIME type
of the document being sent to the client.
14. The _________________ attribute of page directive is used, if you only want to change the
character set.
15. The __________attribute controls whether the page participates in HTTP sessions.
16. __________are user specific not page specific.
17. The __________attribute defines a string that can be retrieved from the servlet by means of the
getServlet-Info method.
18. The __________________attribute indicates whether or not the current page can act as the error
page for another JSP page.
19. The ________________ attributes designates the superclass of the servlet that will be generated
for the JSP page.
20. The _____________attribute is intended to specify the scripting language being used.
Que 6: True False
[1 mark each]
1. The < % return; % > simply aborts the processing of JSP.
2. JSP technology is extensible.
3. We can implement an interface in JSP
4. Request.getServerName () is used to get the name of the server on which the Jsp is running
5. Without using frames we can have a vertical scrollbar with a jsp which in turn is part of other jsp.
6. The jsp:plugin tag is used to insert the browser-specific OBJECTS and EMBED elements.
7. The jsp:useBean attribute is used to indicate the Serialized bean.
8. The JSP page is translated into a servlet and compiled every time it is accessed.
9. A JSP expression is used to insert values directly into the output.
10. JSP works best when the structure of the HTML page is fixed but the values at various places need to
be competed dynamically.
11. If the structure of the page is dynamic, JSP is less beneficial.
12. JSP scriptlets contain Java values and JSP expressions contain Java statements.
13. Scriptlets is used to conditionally output HTML.
14. Exception variable is available in all JSP pages.
15. Response variable is legally used to set HTTP status codes and response headers in the body of JSP
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 21
040010402- Web Application Development
2014
pages.
16. An out variable in JSP is not the standard PrintWriter.
17. Include directive, lets you insert a file into the JSP page at the time the JSP file is translated into
servlet.
18. Import is an attribute of include directive.
19. The core approach of JSP is to put utility classes and beans in packages.
20. The import attribute is the only page attribute that is allowed to appear multiple times within the
same document.
Unit 5: MVC Design pattern
Que: 1 Answer the following question in short.
[1 mark each]
1. What is MVC?
2. Is MVC is an approach or architecture? Justify.
3. What is the basic idea behind using MVC?
4. Why Servlets handles initial request?
5. What are scope variables?
6. Why scoped variables stored in PageContext object is less useful?
7. List out the collection types.
8. Which object is used to easily access context initialization parameters?
9. Why expression language is used?
10. For what purpose expression language operator is used?
Que: 2 Answer the following question in brief.
[2-3 marks each]
1. List out any four need of MVC.
2. List out the expression language operators
3. How to share Request-Based data?
4. What do you mean by Session-Based Data Sharing?
5. What do you mean by Application-Based Data Sharing?
6. What is use of <jsp:forward> tag?
7. What is alternative of forward? Give an example.
8. List out capabilities supported by Expression Language (EL).
9. Write down syntax to invoke EL.
10. Difference between forward and sendRedirect.
11. How to access Scoped variable in JSP?
12. What are implicit Objects?
13. In JSP page how can we handle runtime exception?
14. List out EL operators.
15. How can we disable EL ?
Que: 3 Answer the following question in details.
[4 marks each]
1. What are the advantages MVC?
2. Write down code to share data between JSP and Servlet.
3. How to implement MVC with request dispatcher in detail.
4. Compare Session-Based, Application-Based and Request-Based data sharing.
5. Write note on summarizing MVC code.
6. Explain the capabilities supported by expression language.
7. Explain how to access scoped variables with an appropriate example.
8. Explain how to use Java bean properties in JSP page with an appropriate example.
9. List out the collection types. Explain all in detail.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 22
040010402- Web Application Development
2014
10. Explain the implicit objects used in JSP expression language.
11. Explain expression language operators.
12. How to access bean properties in JSP? Explain with an example.
13. How would you access collection in JSP? Explain with an example.
Que: 4 Select most appropriate answer from the given option.
[1 mark each]
1. What is the role played by JSP in the MVC architecture
a. Model
b. View
c. Controller
d. None of Above
2. The original request is handled by
a. JSP
b. Servlet
c. Container
d. All of above
3. Using which method the servlet can combine its output with that of one or more JSP pages?
a. Include
b. Forward
c. Both (a) and (b)
d. None of the above
4. Which of the following a servlet can do?
a. Invokes business logic
b. Data access code
c. Places the resultant data in beans
d. All of the above
5. If the scoped variable is an object that implements the List interface, the entry name is the
a. Index
b. Value
c. Element
d. None of the above
6. In which interface the entry name is key for implemented scope variable object?
a. Map Interface
b. List Interface
c. Array
d. ArrayList
Que 5: Fill in the blanks.
[1 mark each]
1. _____________ are good at data processing.
2. __________________ are good at presentation.
3. With the request based sharing, the servlet stores the beans in the __________________, where they
are accessible only to the destination JSP page.
4. With session-based sharing, the servlet stores the beans in the ____________, where they are accessible
to the same client in the destination JSP page or in the other page.
5. With the application based sharing, the servlet stores the beans in the _________________,where they
are accessible to any servlet or JSP page in web application.
Que 6: True False
[1 mark each]
1. The include method of RequestDispatcher relies on the destination JSP page to generate the complete
output.
2. JSp page defines a realtively fixed, top-level page appearance.
3. The servlets decides what business logic code applies and which JSP page should present the results.
4. JSP is the controller.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 23
040010402- Web Application Development
2014
Servlet is the page Model.
JSP page is used to handle all the upcoming request on the web server.
Jsp invokes business logic or data access code to obtain the results.
Java bean is store in JSP page.
Jsp is used to create a bean.
10. Servlet do not uses the normal technique to output the results.
5.
6.
7.
8.
9.
Unit 6: Tag Library
Que: 1 Answer the following question in short.
[1 mark each]
1. Where Servlets and other .class files are placed for web application?
2. What is the role of deployment descriptor?
3. Write down location to put Web.xml file in tomcat server.
4. Which element is used for custom url?
5. What is filter?
6. Which interface must be implementing for filters?
7. Which are the three components you need to define for custom tag?
8. Where to define tag attributes in tag library descriptor?
9. What the different types of JSTL tags are?
10. What is use of <c:redirect> tag?
11. Which element is used to register the filter with appropriate Servlets and JSP pages?
Que: 2 Answer the following question in details.
[4 marks each]
1. What is difference between WAR,JAR file in Java?
2. Write a note on any five elements of web.xml file.
3. Write a note on Structure of web applications.
4. Write down basic steps for creating filter.
5. List out filter element’s subelement and filter-maping subelement.
6. Explain reporting filter with steps.
7. What is tag library?Explain in detail.
8. Explain c:out,c:forEach, and C:fortokens tag in detail with an appropriate example.
9. Explain c:if, C:choose, c:set and c: remove tag in detail with an appropriate example.
10. Explain c:import, c:redirect, c:url, c:param and c:catch tag in detail with an appropriate example.
Que: 3 Select most appropriate answer from the given option.
[1 mark each]
1. Name the element within the tag element that defines the name of the class that implements the
functionality of tag. Select the one correct answer.
a.
class-name
b.
tag
c.
class
d.
tag-class
2. How many numbers are printed, when the following JSTL code fragment is executed? Select the one
correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:forEach var="item" begin="0" end="10" step="2">
${item}
</c:forEach>
a. 1
b. 5
c. 6
d. 11
3. What gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 24
040010402- Web Application Development
2014
<c:if test="${var==1}" var="result" scope="session">
<c:out value="${result}"/>
</c:if>
a. The JSTL code does not compile as attribute for if tag are not correct.
b. true
c. false
d. Nothing gets printed.
4. How many numbers gets printed when the following JSTL code fragment is executed? Select the one
correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:choose>
<c:when test="${item>0}">
<c:out value="1"/>
</c:when>
<c:when test="${item==2}">
<c:out value="2"/>
</c:when>
<c:when test="${item<2}">
<c:out value="3"/>
</c:when>
<c:otherwise>
<c:out value="4"/>
</c:otherwise>
</c:choose>
a. No number gets printed.
b. One number gets printed.
c. Two numbers gets printed.
d. Three numbers gets printed.
e. Four numbers gets printed.
5. Which numbers gets printed when the following JSTL code fragment is executed? Select the two
correct answers.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="j" value="4,3,2,1"/>
<c:forEach items="${j}" var="item" begin="1" end="2" varStatus="status">
<c:out value="${status.count}" default="abc"/>
</c:forEach>
a. 1
b. 2
c. 3
d. 4
e. abc
f. The program does not compile.
Que 4: Fill in the blanks.
[1 mark each]
1. To set the welcome file in Java EE, ____________________ attribute is used in web.xml file.
2. To designate specific URL for specific servlet,_____________________ element is used in web.xml file.
3. The ____________________ is not part of Java Compilation Process.
4. A_____________________ is a program that runs on the server before the Servlet or JSP page with
which it is associated.
5. The first argument to the doFilter method is__________________________object.
Ms. Sneha Mandavia, Ms. Jenisha Tailor
Page 25