0% found this document useful (0 votes)
46 views23 pages

CS506 Web Design Final Term Papers 2023

Uploaded by

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

CS506 Web Design Final Term Papers 2023

Uploaded by

bc230408140jan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CS506-Web Design & Development

Final term Current Papers updated (Spring 2023)


Made by RAjpoOt

Contact us: Click here

1. In a web application, WEB-INF folder consist of _________ directories.

A. bin and common


B. logs and temp
C. server and shared
D. lib and classes Correct (Page no 260)

2. To store information during a session, HTTP session object works like a/an ____________.

A. Stack
B. Queue
C. ArrayList
D. HashMap Correct (Page no 314)

3. Which of the following is NOT a stage of servlet lifecycle?

A. Initialize
B. Ready Correct (Page no 267)
C. Service
D. Destroy

4. It is easier to develop dynamic web contents using regular HTML with the help of ______.

A. Swing
B. Applet
C. Servlet
D. JSP Correct (Page no 332)
5. In JSP, declaration tag is used to declare variable and method at __________ level.

A. Program
B. Class Correct (Page no 338)
C. Package
D. Global

6. In java, a thread's priority can be any integer from _________.

A. 1 to 10 Correct (Page no 217)


B. 1 to 100
C. 1 to 1000
D. 1 to 10000

7. Which of the following tag provides global control of JSP?

A. <% ! %>
B. <% @ %> Correct (Page no 327)
C. <% # %>
D. <% = %>

Note: Please also read it. It’s very important

• Directive Elements

Provides global control of JSP……………. <%@%>

• Scripting Elements
JSP comments ……………. <%----%>

declarations……………… <%! %>

o Used to declare instance variables & methods


▪ Expression …….. <%=%>
o A java code fragment which returns String
▪ scriptlets…………… <%%>
o Blocks of java code
• Action Elements
o Special JSP tags ……………. <jsp: .…./>
8. In the context of HttpServletRequest, getHeaderName() method returns ____________ value
if there is no header exists with the specified name.

A. -1
B. 0
C. Null Correct (Page no 294)
D. Not found

9. Which of the following is Not an attribute of JSP page Directive.

A. file ="relativeURL" Correct (Page no 345)


B. extends ="Package.class"
C. errorPage="relativeURL"
D. import ="paclage.*package.class..."

10. In JSP, a Tag Handler class usually ___________ from SimpleTagSupport class that has already
implemented SimpleTag interface.

A. Imports
B. includes
C. extends Correct (Page no 378)
D. implements

11. What does JSP stand for _____________.

A. Java Server Pages Correct (Page no 334)


B. Java Server Protocols
C. Java Service Pages
D. Java Service Protocols

12. JSTL is composed of ________ separate tag libraries.

A. 3
B. 4 Correct (Page no 449)
C. 5
D. 7
13. Which one of the following layers is concerned with application-specific functionalities?

A. Presentation layer
B. Business layer Correct (Page no 419)
C. User interface layer
D. Data layer

14. In the context of HttpServletRequest, getHeaderName() method returns ______ value if there
is no header exists with the specified name.

A. -1
B. 0
C. Null Correct (Page no 284)
D. Not found

15. MVC stands for _____________.

A. Model View Content


B. Model View Controller Correct (Page no 381)
C. Multi View Controller
D. Multi View Content

16. In MVC, the _________ renders the contents of a model and specifies how that data should be
presented.

A. Model
B. View Correct (Page no 395)
C. Page
D. Controller
E.
17. Which one of the following options is Not correct regarding the data layer in 3 layered
architecture?

A. Communicate with database


B. Communicate with XML
C. Communicate with external services
D. Communicate with users Correct (Page no 419)

18. UDDI stands for _________.

A. Universal Description, Discovery & Integration Correct (Page no 470)


B. Universal Data, Discovery & Integration
C. Universal Data, Database & Integration
D. Universal Discovery, Data Integration
19. In Java Server Faces (JSF), expression are delimited with _______.

A. $ {}
B. @ {}
C. # {} Correct (Page no 465)
D. % {}

20. In Java Server Pages (JSP), expression are delimited with _______.

E. $ {} Correct (Page no 465)


F. @ {}
G. # {}
H. % {}

21. JAVA_HOME indicates the root directory of __________.

A. Web Server
B. Website
C. Apache tomcat
D. Java Development Kit Correct (Page no 241)

22. The bracket operator in Expression Language is generally used to retrieve _______ of arrays
and collections.

A. Properties
B. Elements Correct (Page no 440)
C. Values
D. Attributes
23. In applets, _______ method is also called whenever the browser is maximized.

A. start () Correct (Page no 185)


B. paint ()
C. stop ()
D. destroy ()

24. In applets, _______ method is also called whenever the browser is minimized.

A. start ()
B. paint ()
C. stop () Correct (Page no 185)
D. destroy ()

25. JSF is __________ based framework.

A. Request
B. Response
C. Event Correct (Page no 463)
D. Time

26. The dot operator in Expression Language is typically used for accessing the
___________ of an object.

A. Properties Correct (Page no 440)


B. Elements
C. Values
D. Attributes

27. Socket is a ___________ Communication channel between hosts.

A. Uni-directional
B. Bi-directional Correct (Page no 194)
C. Multi-directional
D. Multi-dimensional
28. Serializable Interface belongs to:

A. java.io package Correct (Page no 204)


B. javax.swing package
C. java.net package
D. java.awt package

29. Which of the following database belongs to the JdbcOdbc driver?

A. Oracle database
B. Mysql database
C. SQL database
D. MS Access database Correct (Page no 140)

30. Which of the following layers consists of objects?

A. Presentation layer
B. Business layer
C. Data layer Correct (Page no 314)
D. Both Presentation and Business layer

31. A web application that is a collection of JSPs only is called the ________ approach.

A. Page-centric Correct (Page no 397)


B. Request-centric
C. Session-centric
D. Application-centric

32. Which of the following is not included in simple tag while creating JSP custom tags?

A. Start of tag
B. End of tag
C. Attributes Correct (Page no 367)
D. None of the given options

33. Which of the following tags is NOT included in simple tag while creating JSP custom tags?

A. Start of tag
B. End of tag
C. Tag Name
D. Tag Body Correct (Page no 367)
34. In the context of Session Tracking, storing state on the server side makes _________ really
complicated as states need to be stored for each client.

A. Server Correct (Page no 287)


B. client
C. session
D. servlet

35. Web service are web-based enterprise applications that use open, ________
standards and transport protocols to exchange data with calling clients.

A. XML-based Correct (Page no 467)


B. HTML-based
C. JSP-based
D. DHTML-based

36. Which of the given tag libraries contains tags to support locale messages, text, and numbers
etc?
A. Core
B. SQL
C. XML manipulation
D. Internationalization and formatting Correct (Page no 449)

Note: Please also read it. It’s very important

▪ Core−>contains tags for conditions, control flow and to access variables etc.
▪ XML manipulation−>contains tags for XML parsing and processing
▪ SQL−>contains tags for accessing and working with database.
▪ Internationalization and formatting−> contain tags to support locale messages,
text, numbers and date formation

37. Choose the correct option for blank line given in the following part of Java code public class
MyBean _______________
Serializable {
}

A. Imports
B. Includes
C. Extends
D. Implements Correct (Page no 345)
38. In JSP, a Tag Handler class usually ____________ from SimpleTagSupport class that has
already implemented SimpleTag interface.

A. Imports
B. Includes
C. Extends Correct (Page no 369)
D. Implements

39. The __________ represents the state of the component in MVC.

A. View
B. Model Correct (Page no 395)
C. Controller
D. Component

40. In the context of JSP expressions and scriptlets, which of the following is NOT an implicit
object?

A. Session
B. Exception
C. PageContext
D. PageDirective Correct (Page no 335)

41. In___________, Java code is written inside HTML.

A. Swing
B. Applet
C. Servlet
D. JSP Correct (Page no 324)

42. The default value of scope attribute in JSP useBean action element is _______.

A. Page Correct (Page no 354)


B. Request
C. Session
D. Application

43. JavaBean is a special _______________.

A. Java class Correct


B. Servlet object
C. JSP instance
D. XML file
44. In Java Multithreading, _________________ method can be used for delay purpose.

A. wait ()
B. sleep () Correct (Page no 223)
C. yield ()
D. dispatch ()

45. In the Context of Servlet Lifecycle, which of the following is called each time when a request is
made?

A. Create ()
B. service () Correct (Page no 259)
C. delete ()
D. doPost ()

46. The ________ method of servletConfig object is used to access the initialization parameter of
servlet.

A. getInitParam("param-name")
B. getInitParameter("param-name") Correct (Page no 268)
C. getInitializationParam("param-name")
D. getInitializationParameter("param-name")

47. If the bean object is stored in ________________ then it will be shared by all JSPs/servlets in
the same web application.

A. ServletHistory
B. ServletContext Correct (Page no 362)
C. ServletRequest
D. ServletResponse

48. The return type of getAttribute () method of HttpSession class is ________.

A. Object Correct (Page no 305)


B. Integer
C. Double
D. String
49. Entire JSP page gets translated into a/an _________ once.

A. Swing
B. Applet
C. Servlet Correct (Page no 323)
D. JSF

50. Starvation can occur for __________ priority threads.

A. Same
B. Lower Correct (Page no 218)
C. higher
D. Different

51. Which of the following is NOT appropriate for Page-centric approach?

A. The maintenance of the application becomes a nightmare.


B. A lot of code is also get duplicated.
C. Scaling of such kind of application is easy. Correct (Page no 397)
D. The code becomes a mixture of presentation, business and data access logic.

52. Which of the following directory is the top-level Tomcat directory that contains all the web
application deployed on the server?

A. Webapps Correct (Page no 249)


B. bin
C. lib
D. tags

53. The HTTP response values in the range __________ specify that the request was successful.

A. 100-199
B. 200-299 Correct (Page no 231)
C. 300-399
D. 400-499
54. Which of the following tags is used for comments in JSP?

A. <% ..comments.. %>


B. <% --comments-- %> Correct (Page no 327)
C. <% _ comments _ %>
D. <% = comments = %>
(3 Marks Questions)

Question no 1:

Complete the missing parts from the following piece of code, written for a JSP page
(i.e. myPage.jsp), for displaying course options to the user in the radio buttons form.

1. <html>

2.<body>

3. <h2>Select the page you want to visit</h2>

4. <form name="myform" action="________">

5.<h3>

6.<input type="________" name ="page" value="web"/>servlet

7.</h3>

8. <br>

9.<h3>

10.<input type="________" name ="page" value="web"/>JSP

11.</h3>

12.<br>

13. <input type="________" value="submit"/>

14. </form>

15. </body>

16.</html>

Note: No need to write complete code, just write missing parts

4. <form name="myform" action="________">

6. <input type="________" name ="page" value="web"/>servlet

10. <input type="________" name ="page" value="web"/>JSP

13. <input type="________" value="submit"/>


Answer:

4. <form name="myform" action="myPage.jsp"> <!-- Missing the action URL -->

6. <input type="radio" name="page" value="servlet"/> <!-- Missing the input type as "radio" -->

10. <input type="radio" name="page" value="JSP"/> <!-- Missing the input type as "radio" -->

13. <input type="submit" value="submit"/> <!-- "Type missing-->

Question no 2:

Complete the missing parts from the following piece of code, written Java for creating
cookie object and setting its corresponding attributes

Note: Missing part is represented by underlines.

1. Public void createCookie () {

2. Cookie c= ________________("name" , "value");

3. c.setMaxAge (_________); //1 hour

4. res.addCookie(__________);

5. }

Note: No need to write complete code, just write missing parts

2. __________________________

3. __________________________

4. __________________________

Answer:

2. Cookie c= new Cookie("name" , "value");

3. c.setMaxAge (3600); //1 hour

4. res.addCookie(c);
Question no 3:

On which port number protocols work in the given table. You are required to fill the
table with port number with the corresponding protocol.

Protocol Port Number


FTP
HTTP
TELNET

Answer:

Protocol Port Number


FTP 21
HTTP 80
TELNET 23

Question no 4:

Servlet class hierarchy is given without classes name, write correct order of inherited
classes form given classes that correctly complete this servlet class hierarchy.

GenricServlet

HttpServlet

HttpServletRequest

HttpServletResponse

ServletRequest

ServletResponse
Answer:

Handouts Page no 262

Question no 5:

List down the three-core building block of a Web Service Architecture.

Answer:

Handouts Page no 470

1. Service Description
2. Service Registration (Publication) and Discovery
3. Service Invocation
Question no 6:

There are three stages of a Servlet Lifecycle, list down all of them.

Answer:

Handouts Page no 258

• Initialize
• Service
• Destroy

(5 Marks Question)

Question no 1:

The Following diagram depicts the MVC Model-1 architecture of a typical web
application. You are required to write name components with respect to numbers
given in diagram.

Note: no need to redraw the diagram, rather just write name of components with respect to numbers.
Answer:

Handout Page no 403

1. Browser

2. request

3. response

4. JSP Pages

5. Java Bean

6. servlet container

7. EIS

Question no 2:

Write a servlet that takes three parameters sID, sName, and bGroup from user
through "info.html" form and displays it on the web page.

Note:

• Servlet name should be Myservlet.


• doGet method should be used for getting input and displaying output.

Answer:

html file code:


<html>

<body>

<h2>Please enter the following information:</h2>


<form action="Myservlet" method="get">

Student ID: <input type="text" name="sID"><br>

Student Name: <input type="text" name="sName"><br>

Blood Group: <input type="text" name="bGroup"><br>

<input type="submit" value="Submit">

</form>

</body>

</html>

Using servlet:

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class Myservlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html");

// Reading the parameters from the HTML form

String sID = request.getParameter("sID");

String sName = request.getParameter("sName");

String bGroup = request.getParameter("bGroup");

// Creating the HTML page to be displayed

PrintWriter out = response.getWriter();

out.println("<html><body>");
out.println("<h2>The information entered is:</h2>");

out.println("<p>Student ID: " + sID + "</p>");

out.println("<p>Student Name: " + sName + "</p>");

out.println("<p>Blood Group: " + bGroup + "</p>");

out.println("</body></html>");

Question no 3:

Match Column A with Column B and write the correct option (i.e corresponding layer
as compare to file Column C.

Answer:

Column A Column B Column C


(File) (Layer) (Correct Layer)
Account.html Business Layer Presentation Layer
AcccountBean.java Data Layer Business Layer
AccountDAO.java Presentation Layer Data Layer
AccountServlet.java Presentation Layer Presentation Layer
Account.jsp Business Layer Business Layer

Question no 4:

Being a Java Web Developer, you have been given a task to define two initialization
parameters in a deployment descriptor (web.xml). Define first parameter for text file
(out.txt) and other for DSN (studentDSN)
Answer:

As a Java Web Developer, you can define the initialization parameters in the deployment descriptor
(web.xml) as follows:

<web-app>

<!-- Other configuration elements -->

<!-- Define initialization parameters -->

<context-param>

<param-name>textFileParameter</param-name>

<param-value>out.txt</param-value>

</context-param>

<context-param>

<param-name>dsnParameter</param-name>

<param-value>studentDSN</param-value>

</context-param>

<!-- Servlet and other mappings -->

</web-app>

Code Description: (If you don’t understand the code then read it)

In this example, I've defined two initialization parameters using the <context-param> element.
The <param-name> element specifies the name of the parameter, and the <param-value>
element specifies the value associated with the parameter. You can access these parameters in
your Java code using the getServletContext().getInitParameter("paramName") method, where
"paramName" should be replaced with the actual parameter name you want to retrieve.
Note:
In the Coding section. It indicates comments so that’s why it is not mandatory. It is not part of
coding.
<!-- -->

Question no 5:

You are required to write Java code for building a custom tag handler, named

MyCustomTag, by using "SimpleTagSupport" class and also override "doTag" method,


which will display output like "Welcome to My Custom Tags"

Answer:

Certainly! Here's an example of how you can create a custom tag handler named MyCustomTag that
extends the SimpleTagSupport class and overrides the doTag method to display the desired output:

import javax.servlet.jsp.tagext.SimpleTagSupport;

import javax.servlet.jsp.JspException;

import java.io.IOException;

public class MyCustomTag extends SimpleTagSupport {

@Override

public void doTag() throws JspException, IOException {

getJspContext().getOut().write("Welcome to My Custom Tags");

}
Code Description: (If you don’t understand the code then read it)

In this code, the MyCustomTag class extends SimpleTagSupport, which provides a basic
implementation of the SimpleTag interface. The doTag method is overridden to write
the desired output ("Welcome to My Custom Tags") to the output stream using
getJspContext().getOut().write().

Remember that you need to package this class in a proper Java package, and you'll also
need to configure the tag in the web deployment descriptor (web.xml) and potentially
create a .tld (Tag Library Descriptor) file to define the custom tag.

Question no 6:

The Following Table Contains some Expression Language (EL) based JSTL tag Libraries,

you are required to provide their URL and Correct and correct Prefix

Answer:

Handout Page no 450

You might also like