cs506 final paper 2012

Q.how do v definenad uses error pages in JSP
Q.what is the difference b/w system.out.println() and system.println()
Q.what type of problem persist with structs framework
Q.in which situation expresion language can be used
Q.how can v lead cookies from the clinet
Q.how do v use JSP action element and what are there format
Q.why session tracking is important

5 Marks Quesstions

1. What are packages? and how they are organized?
2. what are output comments in JSP?
3. Write Five operators used in Expression Language

3 Marks Questions

1. When tread’s run() method is invoked?
2. which listener interfaces are used to handle mouse events?
3. why client side validattion is used?
4. Write three types of custom tags
5. how many types of commets are used in JSPs?
6. Differentiate sleeping and yielding in threads

3 Marks Questions

1. Why Expression language is used?
2. why session tracking is used in httpServlets?
3. EJBs and JSP/servlet run on which server?
4. what are streams?
5. Differentiate layers and tiers
6. What is differences between getRequestDispatcher(String path) method using javax.servlet.httpServletRequest or using servletContext?

Tag Library – JSTL
Custom Tags ,and format
JSP action Element

There was one numerical type ( for x = 3, y = 5 , then a loop of if ( X<0 || y > 10 ) x = x*y else x = x+ 1

How session tracking is done in Servlets ,
Problems of structs ( Complexity and none aval of UI tags I remembered)
Over 60 % was from 2008 paper , Best of Luck for all.
YE paper lazmi karma mujhy es main sy bohat zayda aya tha

Solved current paper

There are six JSP Actions:





Identify the advantages of JSP over Servlet.
a) Embedding of Java code in HTML pages
b) Platform independence
c) Creation of database-driven Web applications
d) Server-side programming capabilities

What is JSP Output Comments?
Answer: JSP Output Comments are the comments that can be viewed in the HTML source file.
Example:

and

Question: What is expression in JSP?
Expression tag is used to insert Java values directly into the output. Syntax for the Expression tag is:
<%= expression %>
An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. The following expression tag displays time on the output:
<%=new java.util.Date()%>

Question: What types of comments are available in the JSP?
Answer: There are two types of comments are allowed in the JSP. These are hidden and output comments. A hidden comments does not appear in the generated output in the html, while output comments appear in the generated output.

Example of hidden comment:
<%-- This is hidden comment --%>
Example of output comment:

Question: What is JSP declaration?
Answer: JSP Decleratives are the JSP tag used to declare variables. Declaratives are enclosed in the
<%! %> tag
and ends in semi-colon.

You declare variables and functions in the declaration tag and can use anywhere in the JSP. Here is the example of declaratives:
<%@page contentType="text/html" %>


<%! int cnt=0; private int getCount(){ //increment cnt and return the value cnt++; return cnt; } %>

Values of Cnt are:

<%=getCount()%>

Question: What is JSP Scriptlet?
Answer: JSP Scriptlet is jsp tag which is used to enclose java code in the JSP pages. Scriptlets begins with <% tag and ends with %> tag. Java code written inside scriptlet executes every time the JSP is invoked.
Example:
<% //java codes String userName=null; userName=request.getParameter("userName"); %>

Q.how do we define uses error pages in JSP?
There are two attributes in JSP directive
< @page errorPage= /WEB-INF/error.jsp >
Specifies a JSP page that should process any Exceptions thrown but not caught in the current page.
This Attribute is only related for page-specific error pages only.
< @page isErrorPage= true >
Indicates whether or not the current page can act as the error page for another JSP page.

Q.what is the difference b/w system.out.println() and out.println()
In Jsp i f we want to write some thing to response object we need to use out.println(“some value”);

in java if you want to write some thing to the console then we will write in
System.out.println(“Some thing”)
System.out is a stream to the console, not the response. This output will appear in the console window or log file

Q.what type of problem persist with structs framework
Q.in which situation expresion language can be used
Q.how can v lead cookies from the client

Q.how do v use JSP action element and what are there format

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
-Body body
-Closing tag

Empty tags (without body) can also be used like

Q.why session tracking is important
30 mark of objective

Page directive 5marks
4tag liraries 5 marks
implicit object 2 marks
Implicit Objects
To simplify code in JSP expressions and scriptlets, you are supplied with eight automatically defined variables,
sometimes called implicit objects. The three most important variables are request, response & out. Details of
these are given below:

– request
This variable is of type HttpServletRequest, associated with the request. It gives you access to the
request parameters, the request type (e.g. GET or POST), and the incoming HTTP request headers
(e.g. cookies etc).

– response
This variable is of type HttpServletResponse, associated with the response to client. By using it, you
can set HTTP status codes, content type and response headers etc.

–out
This is the object of JspWriterused to send output to the client.

transient varible 2marks
whst is jsp scriplet 3 marks
what is expression language 3 marks
what is c:remove in jstl 2 marks

c:remove
As its name suggests, the c:remove action is used to delete a scoped variable, and takes two attributes. The var attribute names the variable to be removed, and the optional scope attribute indicates the scope from which it should be removed and defaults to page.

For example, to remove a variable named square from page scope, we’ll write:

And if variable email is required to be removed from request scope, then c:remove tag will look like:

Discuss the MVC model 2 architecture (10marks)
Write the any two types of servelt (2marks)
What is used to join the thread (1marks)
Discuss the JSP Framework (10 marks)
The JSP Framework
— Use regular HTML for most of the pages
— Mark servlet code with special tags
— Entire JSP page gets translated into a servlet (once), and servlet is what actually gets invoked (for each request)
— The Java Server Pages technology combine with Java code and HTML tags in the same
document to produce a JSP file.

Advantages of JSP over php
Versus PHP
— JSPs offer better language for dynamic part
— JSPs offer better tool support

How many types of JSP Comments are (2 marks)
Write the 3 types of JSP Action elements for – (3marks)
What is a package and how to create the package? Explain with an example (5marks)
What is the difference between custom tags and javabeans? (3 marks)
How cookies are sent to a client? (5marks)

MCQ teh
WDSL stands for
UDDI stands for
MVC stands for

From the following; which component is/are used in directory Structure of web components:
_ index.htm, JSP, Images etc..
_ Web-inf, web.xml
_ lib, jar files
_ All of these

From the following which one is not a built-in validator?
_ DoubleRangeValidator
_ LongRangeValidator
_ LengthValidator
_ StringValidator

___________ represent the state of component.
_ View
_ Model
_ Controller
_ Component

When defining a method you must include a ___________ to declare any exception that might be thrown but is not caught in the method.
_ try block_ finally block_ catch block_ throws-clause

Converting bigger data types into smaller one is called ———-

Java provide ——————
_ Overloading
_ Overriding
_ Pointers
_ Multiple Inheritance

5 Marks Quesstions
1. What are packages? and how they are organized?
2. what are output comments in JSP?
3. Write Five operators used in Expression Language

3 Marks Questions

1. When tread’s run() method is invoked?
After a thread is started, via its start() method or that of the Thread class, the JVMinvokes the thread’s run() method when the thread is initially executed.

2. which listener interfaces are used to handle mouse events?
To handle Mouse events, two types of listener interfaces are available.
– MouseMotionListener
– MouseListener
The class that wants to handle mouse event needs to implement the corresponding interface and needs to provide the definition of all the methods in that interface.

MouseMotionListener interface
– Used for processing mouse motion events
– Mouse motion event is generated when mouse is moved or dragged

MouseListener interface
– Used for processing “interesting” mouse events like when mouse is:
ƒ Pressed
ƒ Released
ƒ Clicked (pressed & released without moving the cursor)
ƒ Enter (mouse cursor enters the bounds of component)
ƒ Exit (mouse cursor leaves the bounds of component)

3. why client side validation is used?

4. Write three types of custom tags
Three types of can be constructed. These are:
1 Simple Tag
2 Tag with Attribute
3 Tag wit

1. Simple Tag
A simple tag has the following characteristics:
-Start and End of tag -No body is specified within tag -No attributes -For example

2.Tag with Attributes
A tag with attributes has the following characteristics:
-Start and End of tag
-Attributes within tag
-No body enclosed
-For example
< mytag:hello attribute = “value” />

3. Tag with Body
A tag with body has the following characteristics:
-Start and End of tag
-May be attributes
-Body enclosed within tag
-For example
< mytag:hello optional_attributes ………… >
some body

5. how many types of commets are used in JSPs?
Comments are ignored by JSP-to-servlet translator. Two types of comments are possibly used in JSP.
– HTML comment:
These comments are shown in browser, means on taking view source of the web page; these sorts of comments can be read. Format of HTML comments is like to:

– JSP comment:
These comments are not displayed in browser and have format like:
<%-- comment text --%>

6. Differentiate sleeping and yielding in threads
1. Why Expression language is used?
2. why session tracking is used in httpServlets?
3. EJBs and JSP/servlet run on which server?
4. what are streams?
5. Differentiate layers and tiers
Layers vs. Tiers
Layers are merely logical grouping of the software components that make up the application or service,whereas Tiers refer to the physical residence of those layers.
In general,
. Layers – represents the logical view of application
. Tiers – represents physical view of application

6. What is differences between getRequestDispatcher(String path) method using javax.servlet.httpServletRequest or using servletContext?

WHAT is validation? Describe build-in validator?
why servlets are used as controller in JSP are never used?
what is JSP? why its used? n also explain JSP framwork?
What is the typical use of Hash table?
Whenever a program wants to store a key value pair, one can use Hashtable.

DOWNLOAD SOLUTION HERE
loading...