CS506 Finalterm Paper 2013 File 7 Solved

No Comments

My Today Solved  paper of 506 .16 July 16, 2012

Hina Nosheen





Question #1

What are the three stages of Servlet Lifecycle? (3 Mark) Answer:- (Page 267) A servlet passes through the following stages in its life.

1 Initialize

2 Service

3 Destroy

Question #2

Why is direct call of paint() method not recommended?

Answer:- (Page 191 ) Painting is managed by system, so calling paintComponent() directly is not recommended at all. Similarly calling paint ( ) method is also not recommended. Why? Because such code may be invoked at times when it is not appropriate to paint -- for instance, before the component is visible or has access to a valid Graphics object.





Question #3





Which Five operators are used in Expression Language






Type




operator




Arithmetic




+   _   * \ (div) % (mod)




Grouping




( )






Logical




&&(and) ││(or) !( not)




relational


==(eq) !=(ne) <(lt) >(gt) <= (le) >= (ge)








Empty


The empty operation is a prefix operation used to determine if a value is null or empty. It returns a Boolean value




Conditional


?:




Question #4

What is Expression in JSP? Give an example. (5 Mark) Answer:-

(Page 335) The format of writing a Java expression is: <%= Java expression %> These expressions are evaluated, after converted to strings placed into HTML page at the place it occurred in JSP page Examples of writing Expressions are:

 <h2> Time: <%= new java.util.Date() %> </h2>

 will print current data & time after converting it to String

 <h2> Welcome: <%= request.getParameter(―name‖)%> </h2>

will print the name attribute





Question #5

Why do we need Expression language? Answer:- (Page 451)

The Expression Language, not a programming or scripting language, provides a way to simplify expressions in JSP. It is a simple language that is geared towards looking up objects, their properties and performing simple operations on them. It is inspired form both the ECMAScript and the XPath expression language.





Question #6

What are action elements of JSP? How these are written. (5 Marks) Answer:

-         (Page 367) JSP Action Elements JSP action elements allow us to work with JavaBeans, to include pages at request time and to forward requests to other resources etc.

-         Format Expressed using XML syntax

-          -Opening tag <jsp:actionElement attribute=”value” ….. >

-          -Body body

-         -Closing tag </jsp:actionElement>

 Empty tags (without body) can also be used like <jsp:actionElement attribute=”value” ….. >

Some JSP Action Elements

To work with JavaBeans

-<jsp:useBean />

 -<jsp:setProperty />

-<jsp:getProperty />

To include resources at request time

-<jsp:include />



To forward request to another JSP or Servlet -<jsp:forward />

 To work with applets

-<jsp:plugin />



-        



Question #7

Why Client side Validation Good?(page 480)

Answer   There are two good reasons for client side validation

-          It’s a faster form of validation: if something’s wrong, the alarm is triggered upon submission of the form

-          You can safely display only once error at a time and focus  on the wrong field,to help ensure that the  the users correctly fill all the detail you need

-          



Question #8

How cookies are sent to a client? Answer:- (Page 299)

 Sending Cookies to Browser Following are some basic steps to send a cookie to a browser (client)

. 1.Create a Cookie Object A cookie object can be created by calling the Cookie constructor,

which takes two strings: the cookie name and the cookie value.

 Cookie c = new Cookie (―name‖, ―value‖);





2. Setting Cookie Attributes

 Before adding the cookie to outgoing headers (response), various characteristics of the cookie can be set. For example, whether a cookie persists on the disk or not. If yes then how long. A cookies by default, lasts only for the current user session (i.e. until the user quits the session) and will not be stored on the disk.

 Using setMaxAge(int lifetime) method indicates how much time (in seconds) should elapse before the cookie expires.

 c.setMaxAge(60); // expired after one hour

3. Place the Cookie into HTTP response After making changes to cookie attributes, the most important and unforgettable step is to add this currently created cookie into response. If you forget this step, no cookie will be sent to the browser

. response.addCookie(c);





Question #9



Why do we use session tracking in HTTP servlets?

Answer:-  In HttpServlet we can use Session Tracking to track the user state. Session is required if you are developing shopping cart application or in any e-commerce application.



Question #10

How MVC work with JSP page,servlet,Html

Answer

(page no 410 )

.

Question #11

How can we use a existing Database by using JDBC write the steps?

Question #12



What is abstract  classes

Answer on page #96  handout
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment