0% found this document useful (0 votes)
8 views4 pages

Java Web Programming Midterm Exam Guide

The document is a midterm examination paper for the course BIWP324: Web Programming with Java, dated 05/04/2019, worth 20% of the overall semester assessment. It consists of three sections with a total of 60 marks, including multiple-choice questions in Section A and programming tasks in Section B. Candidates are instructed to answer all questions and return all examination materials upon completion.

Uploaded by

lekhotlamphohali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Java Web Programming Midterm Exam Guide

The document is a midterm examination paper for the course BIWP324: Web Programming with Java, dated 05/04/2019, worth 20% of the overall semester assessment. It consists of three sections with a total of 60 marks, including multiple-choice questions in Section A and programming tasks in Section B. Candidates are instructed to answer all questions and return all examination materials upon completion.

Uploaded by

lekhotlamphohali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

BIWP324· WEB PROGRAMMING WITH JAVA

MIDTERM EXAMINATION

Faculty : Information and Communications Technology


Date/Day : 05/04/2019
Duration : 2 hours

INFORMATION FOR CANDIDATES

1. This examination is worth 20% of the overall semester assessment.


2. The total number of marks available for this examination is 60.
3. This examination paper contains THREE (3) sections in FOUR (4) printed pages
including the cover page.

INSTRUCTIONS TO CANDIDATE

a) Answer ALL questions in Section A and B.


b) Write all your answers in the answer booklet provided.
c) If you make a mistake please put a single diagonal line through the section you wish
to be ignored by the examiner.
d) Return all examination papers and scripts upon completion of the examination
including any workings.
SECTION A [10 Marks]

1. Which of the following is not a implicit object?


A - request
B - response
C - cookie
D – session
2. response is instance of which class?
A - Response
B - HttpResponse
C - HttpServletResponse
D - ServletResponse
3. This object can be used to access other implicit objects in JSP.
A - request
B - page
C - context
D - pageContext
4. Which of the following is not a directive?
A - include
B - page
C - export
D – useBean
5. Which of the following is a server side technology?
A - html
B - jsp
C - javaScript
D - css
6. Consider the following code and select the correct statement about it from the
options below.
<%! int aNum = 5%>
The value of aNum is <%= aNum%>
(A) It will not flag any compile-time or runtime errors and will not print anything to the output.
(B) It will print "The value of aNum is 5" to the output.
(C) It will flag a compile-time error because of an incorrect declaration.
(D) It will throw a runtime exception while executing the expression.
7. Which of the following tags can you use to print the value of an expression to the
output stream?
(A) <%@ %>
(B) <%! %>
(C) <% %>
(D) <%= %>
8. The following declaration is valid or not?
<%@ page import="[Link].* " %>
<%@ page session="true" %>
<%@ page import="[Link].*" %>
(A) Valid
(B) Invalid
9. What will be the output of the following code?
<% int x = 5; %>
<%! int x = 10; %>
<%! int y = 50; %>
The value of b multiplied by a is <%= y * x %>

10. Which is not a implicit object in JSP?


a) pageContext
b) pageConfig
c) config
d) context
e) page
f) exception
g) Exception

(A) b,d and f


(B) b,d and g
(C) a,c and g
(D) a,b and e
SECTION B. [50 Marks]
1. Write a JSP program using the following implicit JSP objects,session,request,response
and out to implement user login [Link] user should be redirected to the
relevant JSP page depending on successful or unsuccessful login. [20 Marks]
2. Write a JavaBean Program named Students with the following properties:
FullName,Age and [Link] properties should have relevant getter and setter
[Link] useBean action along with its associated properties to access the
relevant getter and setter [Link] should finally be displayed on the browser.
[20 Marks]
3. Clerk has opened a dealer shops that trades in HP computer accessories. Customers
can either purchase on cash or account/credit with a repayment period of 3months. A
10% interest is charged for credit customers. Write a JSP program to store and display
the information of the dealer shop.
[10 Marks]

Common questions

Powered by AI

The JSP 'page' directive controls Java class imports through the 'import' attribute. This directive specifies which Java classes or packages are imported, affecting how the JSP page accesses classes and utilizes their functionalities. Well-organized imports prevent name conflicts and optimize performance by minimizing unnecessary class loading. Proper use enhances code structure and maintainability by ensuring the necessary classes are available for the page's operation without cluttering with redundant imports .

Implementing user login verification in JSP involves using implicit objects like 'session', 'request', 'response', and 'out'. The process starts by capturing user input via the 'request' object. User credentials are then validated against stored data, typically within a session-managed environment. Based on validation, 'response' redirects users to appropriate JSP pages for successful or unsuccessful login, while 'out' is used to display messages. Key considerations include secure data handling, session management for storing user state, and preventing unauthorized access .

JSP directives, like 'page' and 'include', play a crucial role in web application structure and performance. The 'page' directive manages the JSP page's global attributes, such as language or importing classes, impacting how the page behaves at runtime. The 'include' directive enables static resource inclusion, sharing code between pages for better maintainability. By optimizing resource management and code reuse, these directives improve application performance and reduce redundant coding efforts .

Integrating JavaBeans with JSP enhances web application functionality by separating business logic from presentation. JavaBeans encapsulate functionality in reusable components with getter/setter methods that JSP pages can access using the 'useBean' action. This modular approach facilitates maintenance and scalability while promoting code reusability. The JavaBean properties, accessed through JSP, provide an efficient means to manage user or system data seamlessly between the client interface and server-side operations .

A common compile-time error arises when using JSP declarations instead of expressions due to incorrect syntax. Declarations ('<%! %>') are for class-level variables and methods, whereas expressions ('<%= %>') are for outputting values. Misusing a declaration where an expression is needed, such as attempting `The value is <%! value %>`, results in errors owing to incompatible contexts. Understanding the correct usage of each syntax is crucial to avoid errors and ensure the intended functionality .

Implicit objects and scriptlets in JSP serve different purposes. Implicit objects are pre-defined, making it easier to interact with the server and manage dynamic content without detailed implementation. They enhance code readability and maintainability by minimizing Java code within JSP pages. Scriptlets, on the other hand, allow embedding Java code directly in the JSP, offering flexibility but potentially reducing readability and maintainability due to increased code intermix. Favoring implicit objects over scriptlets encourages clearer separation of logic and presentation layers .

Server-side technologies like JSP are significant in web development due to their capability to manage complex business logic, session management, and dynamic content generation securely on the server. Unlike client-side technologies, which handle user interface and client-device interactions, server-side technologies reduce client load and enhance security by processing data and business logic server-side before delivering HTML/CSS to clients. This division of concerns allows for efficient handling of requests and personalized responses, crucial for robust web applications .

Session management in JSP using the 'session' implicit object is central to maintaining user state across multiple requests. It tracks user-specific data like login credentials, preferences, or shopping cart details during a session. The 'session' object, usually an instance of HttpSession, provides methods to store and retrieve user data, enhancing user experience by personalizing interactions and maintaining continuity. Effective session management is critical for applications needing persistent user interactions, ensuring data integrity and application performance .

Implicit objects in JSP, such as 'request' and 'response', are pre-defined variables provided by the JSP container that facilitate interaction between the server and client. The 'request' object is an instance of HttpServletRequest, allowing access to HTTP request data, including parameters and headers. The 'response' object, an instance of HttpServletResponse, is used to direct output to the client, modify response headers, and manage cookies . Together, they enable seamless communication and coordination in Java web programming.

The 'useBean' action in JSP simplifies JavaBean management by instantiating JavaBeans and binding them to JSP pages. This action includes setting bean properties using 'setProperty' and accessing data through 'getProperty', aligning view logic closely with business logic. It reduces the complexity of data handling, ensures data encapsulation, and promotes reusability by leveraging JavaBean properties. This integration streamlines web development, aligning back-end functionality with the presentation layer efficiently .

You might also like