O Classloader Is A Subsystem Of: JVM That Is Used To Load Class Files
O Classloader Is A Subsystem Of: JVM That Is Used To Load Class Files
Classloader
o Classloader is a subsystem of
JVM that is used to load class
files
1. BootStrap ClassLoader
2. Extension ClassLoader
3. SystemClassLoader
o Bootstrap class loader loads all
java core classes, which are at
the part of runtime.
Bootstrap ClassLoader JRE/lib/rt.jar
o
o
Emp.java
Composition
Emp.java
String
Translation
Compilation
jspInit() invocation
_jspService() invocation
jspDestroy() invocation
<%!
public void jspInit() {
. . .
%>
<%!
. . .
%>
8.What are implicit objects in JSP?
Implicit objects in JSP are the Java objects that the JSP
Container makes available to developers in each page.
These objects need not be declared or instantiated by
the JSP author. They are automatically instantiated by
the container and are accessed using standard variables;
hence, they are called implicit objects.The implicit
objects available in JSP are as follows:
o
request
response
pageContext
session
application
out
config
page
exception
Include action
The include directive is used to statically insert the contents The include standard action enables the curren
of a resource into the current JSP.
include a static or a dynamic resource at runtim
Use the include directive if the file changes rarely. Its the
fastest mechanism.
The <jsp:getProperty> action is used to access the properties of a bean that was set using the
<jsp:getProperty> action. The container converts the property to a String as follows:
Here, name is the id of the bean from which the property was set. The property attribute is the
property to get. A user must create or locate a bean using the <jsp:useBean> action before
using the <jsp:getProperty> action.
24.What is the <jsp:param> standard action?
The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter
names and values to the target resource. The syntax of the <jsp:param> standard action is as
follows:
<jsp:param name="paramName" value="paramValue"/>
Servlet
What is the Servlet?
A servlet is a Java programming language class that is used to extend the capabilities of servers
that host applications accessed by means of a request- response programming model.
2.What are the new features added to Servlet 2.5?
Following are the changes introduced in Servlet 2.5:
Note: Most Servlets, however, extend one of the standard implementations of that interface,
namely javax.servlet.GenericServlet andjavax.servlet.http.HttpServlet.
GenericServlet
The GenericServlet is an abstract class that is extended by HttpServlet to
provide HTTP protocol-specific methods.
The GenericServlet does not include protocol-specific methods for handling request
parameters, cookies, sessions and setting response headers.
doGet()
doPost()
It disallows bookmarks.
If data is sensitive
17.How do I support both GET and POST from the same Servlet?
The easy way is, just support POST, then have your doGet method call your doPost method:
The param-value pairs for ServletConfig object are specified in the <init-param>
within the <servlet> tags in the web.xml file
forward()
A forward is performed internally by the servlet.
The browser is completely unaware that it has taken place, so its original URL
remains intact.
Any browser reload of the resulting page will simple repeat the original request, with
the original URL
Both resources must be part of the same context (Some containers make provisions
for cross-context communication but this tends not to be very portable)
Since both resources are part of same context, the original request context is retained
If you include a servlet or JSP document, the included resource must not attempt to
change the response status code or HTTP headers, any such request will be ignored.
Peop
24.What's the use of the servlet wrapper classes??
The HttpServletRequestWrapper and HttpServletResponseWrapper classes are designed
to make it easy for developers to create custom implementations of the servlet request and
response types. The classes are constructed with the
ServletContext.ge
The getRequestDispatcher(S
ofjavax.servlet.ServletCon
All path must start with a / a
context root.
28.What is preinitialization of a
servlet?
A container does not initialize the servlets as soon as it starts up, it initializes a servlet when
it receives a request for that servlet first time. This is called lazy loading. The servlet
specification defines the element, which can be specified in the deployment descriptor to
make the servlet container load and initialize the servlet as soon as it starts up. The process
of loading a servlet before any request comes in is called preloading or preinitializing a
servlet.
29.What is the <load-on-startup> element?
The <load-on-startup> element of a deployment descriptor is used to load a servlet file
when the server starts instead of waiting for the first request. It is also used to specify the
order in which the files are to be loaded. The <load-on-startup> element is written in the
deployment descriptor as follows:
<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>ClassName</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Note: The container loads the servlets in the order specified in the <load-on-startup>
element.
What is Servlet Chaining?
Servlet Chaining is a method where the output of one servlet is piped into a second servlet.
The output of the second servlet could be piped into a third servlet, and so on. The last
servlet in the chain returns the output to the Web browser.
43.How are filters?
Filters are Java components that are used to intercept an incoming request to a Web resource
and a response sent back from the resource. It is used to abstract any useful information
contained in the request or response. Some of the important functions performed by filters
are as follows:
Security checks
Data compression
Response compression
Filters are configured in the deployment descriptor of a Web application. Hence, a user is not
required to recompile anything to change the input or output of the Web application.
44.What are the functions of an intercepting filter?
The functions of an intercepting filter are as follows: