Вы находитесь на странице: 1из 8

Sl No 1 2

Question JSP is an acronym for ? Which of these is correct?

Choice A Java Script Pages JSP technically can do anything servlets can't do send an <IMAGE > tag to the client Servlet code gets executed

Choice B Java Servlet Pages ans) JSP technically can't do anything servlets can't do send an <IMAGES > tag to the client ans) JSP constructs get translated to Servlet code JSP constructs get translated to Servlet code Page translation happens for each request. out.print("<H1><%Hi%></H 1>" ans) Will never be sent to the client <@<%-- comment --%@> Taking the instance out of service <\\% ans) <%= expression %> <% =code %> <% =code= %> ans) <%= request.getRemoteHost( Response

Choice C ans) Java Server Pages JSP technically can do anything HTML cant do ans) send an <IMG > tag to the client Interpretation of JSP code occurs ans) Interpretation of JSP code occurs A or B out.print("<H1><!Hi-!></H1>" Shall be sent to the client on every request. ans) <%-- comment --%> ans) Each request, passing the request and response objects ans) <\% <!expression--!> <%! code %> <#% code %#> <% request.getHostName( Out

Choice D None of the Above JSP technically cant do anything HTML can do None of the above None of the above

Choice E

3 4

How do I put an image in a JSP page? At Page translation time.?

5 6 7

What happens at Request time?. When does Page translation occur? HTML text <H1>Hi</H1> when turned to servlet code is? JSP Hidden comment ? Syntax of Hidden Comment ? jspservice() is called for

Servlet code gets executed ans) First time JSP page is accessed after its modified ans) out.print("<H1>Hi</H1>" Would be sent only on first request to client <!-- comment [ <%= expression %> ] --> Initialising a servlet instance <%% <%= expression= %> ans) <% code %> <% code %> <%= request.getHostName(

None of the above None of the above either b or c

8 9 10

None of the above None of the above All of the Above

11 12 13 14 15

To get <% in output use, ? Format for expressions ? Format for Scriplets ? Format for Declarations To get the HostName ?

None of the above <^% expression %^> <%!code =%> ans) <%! code %> <% request.getRemot eHost( ans) None of the

16

Which of these is not a

Request

17

18

predefined variable ?. Which of these gives information about the container ? For request.getRequestDispatch er(path ? Which of these is not an implicit object ? How to use comments within a JSP page ? Page Directive can control ? Format for import ?

ans) ServletContext

PageContext

RequestDispatcher

above sendRedirect

ans) we need to give the relative path of the resource request <%-- the scriptlet is now commented out--%> Which classes are imported

we need to give the absolute path of the resource pageContext <!-- (c 2004 -->

Absolute or Relative Path is irrelevant ans) in ans) Both A and B How multithreading is handled <%! page import="package.class" %> ans) <%@ page session="true" %> Saves CPU time on server if you have a hightraffic site ans) <%@ page buffer="none" %> Servers are allowed to use a larger size than you ask for, but not a smaller size ans) <%@ page errorPage="Relative URL" %> Global Error Pages Null Can help system from using high-performance custom superclasses

None of the above

19 20 21 22

out None of the abocve ans) All of the Above <%# page import="package.c lass" %> <%@ page session "true" %> ans) A and B

What class the servlet extends ans) <%@ page <% page import="package.class" %> import="package.class" %> <%@ page session=true %> Page session attribute by default is false <% page buffer="none" %@> Buffering gives the size of the buffer used by the out variable <%@ page_errorPage="Relative URL" %> ans) Page Specific Error Pages TRUE Extends attribute is used to extend our own classes <%@ !page session="true" %> Saves memory on server if you have a high-traffic site <%@@ page buffer="none" %> Buffering lets you set HTTP headers even after some page content has been generated <%@ page errPage="Relative URL" %> Generalised Error Pages ans) FALSE Specifies parent class of servlet that will result from JSP page

23 24

Format for session attribute ? Which of these is correct ?

25 26

Format of Buffer Attribute ? Which of these is incorrect ?

<%@page buffer="none"> ans) Default is system-specific, but must be at least 16kb <%@ page errorPage="Relativ e URL"@%> None of the Above Undefined ans) A and C

27

Error Page Attribute is ?

28 29 30

ErrorPage Attribute is for ? Default value of isErrorPage attribute ? Which of these about Extends Attribute is incorrect ?

31 32

isThreadSafe attribute tells the ? Which of these holds good for Java Beans ? jsp:useBean is used for ? jsp:getProperty is used for ? Which of these is not a scope variable for <jsp:useBean>? Which jsp tag can be used to retrieve a property of a bean? Identify the implicit objects accessible to a jsp page that can store objects accessible across multiple requests. Which of the following statements are valid JSP directive?

ans) system when your code is not threadsafe Should have no public instance variables ans) Creating or accessing a bean Modify the value of a bean property page

system when your code is threadsafe Must have a zero-argument (empty constructor) Delete a Bean ans) Read the value of a bean property request

servlet to implement Multiple Thread Model Persistent values should be accessed through get and set methods Set properties of the bean Both A and B ans) output

A and B ans) All of the Above None of the above None of the Above application

33 34 35

36

jsp:useBean

jsp:useBean.property

jsp:useBean.getProperty

ans)jsp:getPropert y ans) application

jsp:property

37

page

request

response

pageContext

38

<%! int k = 10 %>

<% int k = 10; %>

<%=somevariable%>

%@ taglib uri="https://www. abcd.com/tags/util " prefix="util" %

ans) <%@ page language="j ava" import="co m.abc.*"%> javax.servlet. jsp.HttpJspSe rvlet ans) PageContext

39

Which of the following interfaces declares the methods jspInit() and jspDestroy()? Which of the following classes hides the implementation details and provides a standard API to the services provided by the servlet container to a jsp

javax.servlet.jsp.JSP

javax.servlet.jsp.JspServlet

ans)javax.servlet.jsp.Jsp Page

javax.servlet.jsp.Ht tpJspPage

40

HttpSession

Servlet

JspPage

ServletContext

page?

41

You have declared a useBean tag as: <jsp:useBean id="man" class="animal.Human" scope="application"/> In which type of object will this bean be kept?

Servlet

HttpSession

ans)ServletContext

ServletConfig ApplicationC ontext

42

Which of the following packages are implicitly imported in the JSP page? Select the correct order that JSP methods are invoked by servlet container If precompile option set to false, for the first time request JSP page takes little more time then subsequent request, is it true? If JSP has option "isThreadSafe=false" set, only one instance will serve all the request. There is no way in JSP you can ask container to have single threaded implementation?

java.lang;

java.util.*

javax.servlets.*

ans) javax.servlet.jsp.*

javax.servlet. jsp.tagext.*

43

jspInit(), jspService(), jspDestroy() ans)True

ans)jspInit(), _jspService(), jspDestroy() FALSE

_jspInit(), jspService(), _jspDestroy()

_jspInit(), _jspService(), _jspDestroy()

44

45

TRUE

ans) FALSE

46

TRUE

ans) FALSE

47

JSPs cannot contain JAVA code. JSP gets converted into a servlet behind the scenes. What will be the output of the following JSP code? <html><body> <% int a = 10; %> <%! int a = 20; %> <%! int b = 30; %> The value of b multiplied by a is <%= b * a %> </body> </html>

TRUE

ans) FALSE

48

ans)True

FALSE

49

The code will not compile

The value of b multiplied by a is 30

ans)The value of b multiplied by a is 300

The value of b multiplied by a is 600

The value of b multiplied by a is 0

50

The jsp:plugin tag is used to insert the browser-specific OBJECTS and EMBED elements Which of the followings cannot be a scope of an object in a jsp page. Which of the following gets or sets the bean in the servletContext container object? Which of the following is valid about include directive in jsp? Which tag in the jsp is used to define the error page. Java Server Pages specification includes

ans)True

FALSE

51

Application

Request

Page

ans)Response

52

<jsp:useBean id=address class=test.addressBean /> Used for dynamic inclusion

ans)<jsp:useBean id=address class=test.addressBean scope=application /> ans) Used for static inclusion location

<jsp:useBean id=address class=test.addressBean scope=servlet />

None of the above

53

54

None of the above

exception-type

ans) error-page

55

ans)Script language declarations, scriplets and expressions

JSP standard actions

JSP standard directives

A portable tag extension mechanism

56

Which codeline must be set before any of the lines that use the PrintWriter Following method(s) cannot be overridden in the JSP page Which of the following statement is true for the include directive Which of the following are the JSP scripting elements What tools can be used to generate the multiple views in jsp Which of the following is legal JSP syntax to print the value of i. Which of the following are correct?

setContentWriter()

setWriter()

setPrintType()

ans) setContentType() getParameter()

57

jspDestroy()

jspInit()

jspService()

58

Can be used to incorporate contents from static documents Declarations

ans)It offers option of sharing local variables and better run time efficiency Scriptlets

Provides benefit of automatic recompilation expressions ans) All the above

59

60

xalan-Java

ans) Saxon

Jdk1.5

None of the above

61

<%int i = 1;%> <%= i; %>

<%int i = 1;i; %>

<%int i = 1%> <%= i %>

<%int i = 1;%> <%= i %> ans) To use the character %> inside a scriptlet, you may use %\> instead. ans)response

ans) <%int i = 1%><%= i; %>

62

JSP scriptlets and declarations result in code that is inserted inside the _jspService method. application

The JSP statement <%! int x; %> is equivalent to the statement <jsp:scriptlet>int x;</jsp:scriptlet%>. session

63

Which of the following can not be used as the scope when using a JavaBean with JSP? The implicit JSP objects like request, response, and out are only visible in the _jspService() method.

The following are some of the predefined variables that maybe used in JSP expression httpSession, context. request

page

64

ans)True

False

65

Which of the following staments are correct about the following jsp lines: <jps:useBean id=name class=java.lang.String /> <%= name %>

It won't compile

ans)It is a valid jsp line and it will print the variable called name

It will compile but it will always produce null as the output

It will work if you create a javabean class with only one variable of type java.lang.String

66

Which of the following are mandatory elements of the tagLibrary descriptor file? What is the difference between forward and sendRedirect?

tlib-version

jsp-version

short-name

tag

ans) All of the above

67

68

What is difference between custom JSP tags and beans?

69

Which method is used to retrieve a form value in a JSP or Servlet?

ans)RequestDispatcher: server-side redirect with request and response objects.sendRedirect : Client-side redirect with new request and response objects. Custom tags are available only in JSP 1.2 and later, but beans can be used in all JSP 1.x versions. request.getAttribute(String )

RequestDispatcher: clientside redirect with request and response objects.sendRedirect : Server-side redirect with new request and response objects. ans) Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions. response.getAttribute(Strin g) include

ans)request.getParamet er(String) taglib

response.getPara meter(String) ans) forward

70

Which of the following is not page a valid JSP directive? The above tags in your jsp file will: <jsp:useBean id="people" scope="session" class="bean.People"/> <jsp:setProperty name="people" property="*"/> Create a bean of People.class that will exist for all pages changed on this request.

71

ans) Retrieve a bean of People.class from the session if one exists or create a new one and store it in the session.

Create a Bean of People.class that is available to all classes in your application.

Create a bean of People.class that will go out of scope when the page is completed.

72

If you want to write a method in JSP, within what type of tags must you declare the method? which of the following are <jsp:plugin > attributes? Syntax for Expression scripting element?

<@ @>

<%@ %>

<% %>

ans) <%! %>

73

type

ans)codebase

url

align

class

74

<% = Expression; %/>

<jsp:Expression > Expression </jsp:Expression>

ans)<%= Expression; %>

<%= Expression %>

Вам также может понравиться