Shared Flashcard Set

Details

JSP/Servlets week 2
Week 2 Multivision
22
Software
Undergraduate 4
04/28/2013

Additional Software Flashcards

 


 

Cards

Term
What is the difference between HTTP Post and HTTP Get?
Definition
Get is essentially for getting data. Post may involve anything like storing,updating data, ordering a product or sending email. Get is encoded in the URL. Post is stored within the message body. Use get when details of the message have no effect. Use post when the details need to be hidden. Get also has limited data capacity whereas Post does not.
Term
What is the life cycle of a Servlet?
Definition
init(), service(), destroy()
Term
What is the life cycle of a JSP?
Definition
page translation, compilation, load , instantiate, jsp_init(), jsp_service(), jsp_destroy()
Term
What is the difference between a Generic Servlet and an HTTP Servlet?
Definition
javax.servlet.Servlet is the central interface in the Servlet API. Every servlet class must implement this interface. It has 5 methods init(), service(), destroy(), getServletConfig() and getServletInfo()

a) Generic servlet implements the servlet interface. It is an abstract class that provides implementation for all methods except the service() method. We can extend this class and implement the service method to write any type of servlet.

b)HTTP Servlet extends the generic servlet . It provides support for the HTTP protocol it adds a new service() method with the signature service(HTTP request, HTTP response) For every HTTP method, there is corresponding method in the HTTPServlet class(doGet, doPost)
Term
How do you preinitialize/preload a servlet?
Definition
The servlet specification defines the element which can be defined in the deployment descriptor to make the web container load and initialize the servlet as soon as it starts up.
Term
What is a ServletConfig?
Definition
ServletConfig is defined in the javax.servlet package. It provides 4 methods. getInitParameter(String),getInitParameters and getServletName. A servlet container takes the information specified in the deployment descriptor and wraps it into a ServletConfig object. This information can then be retrieved by the servlet at initialization. It is passed as a parameter to the init method init(javax.servlet.ServletConfig).
Term
What are important tags in the ServletConfig?
Definition
)
Term
What is a servlet context?
Definition
The servlet context is a window for a servlet to view its environment. Every web application has a single Servlet Context that is available to all resources in the application.It is used by the servlets to share data with each other. A servelt can use this information such as initialization parameters for the web application or servlet container version. This interface also provide utility methods for retrieving MIM type for a file, for retrieving shared resources and logging.
Term
Name some important ServletContext tags
Definition
Term
How would you forward a request from a servlet to a JSP?
Definition
Using a request dispatcher.

RequestDispatcher dispatcher = httpServletRequest.getrequestDispatcher(url)

dispatcher.forward(httpServletRequest, httpServletResponse)
Term
What is the difference between the RequestDispatcher.forward() and HttpServletResponse.SendRedirect()?
Definition
forward() is handle completely on the server side.redirect sends a redirect message to the browser. Forward is transparent to the user. Redirect is not. Both javax.servletServletContext and javax.servlet.ServletRequest have the getRequestDispatcher(path) method.
Term
What directory does the Deployment Descriptor reside(web.xml)?
Definition
root\WEB-INF
Term
What does JSTL stand for?
Definition
JSP Standard Template Library.
Term
What are the various types of markup tags in a JSP
Definition
a) Directives (page, includes and tag lib)

b) Scripting elements
i <%!Declarations%> Declarations allow the developer to define various variables and methods in a page.

ii Scriptlets are lines of code that is executed each time a process request is made.

iii <%= Expression%> is an individual line of code.

c) comments
d)actions
Term
What are the various scope is a JSP
Definition
Page, Request,Session and Application
Term
Name the implicit objects in JSP
Definition
Session -User Specific session data
Exception/Error - uncaught exception
Application Data shared by all pages in application.

Config- Servlet configuration data
Request- Request data including parameters

Response- Response data
Out- output stream for page
Page- Page servelet instance
Page Context -Context data for page execution
Term
Name some action tags in JSP
Definition
a
b
c is used to generate browser specific HTML for specifying Java applets that rely on a JAVA plugin.

d)
Term
What are directives? Can you name some directives in JSP.
Definition
Directives are used to convey special processing information about the page to the JSP container

a) <%@ page attri="val1"...%>
There are a list of attributes supported by the page directive. info, language, contextType, pageEncoding, extends, import, session, buffer, autoFulsh, isThreadSafe, isErrorPage

i isErrorPage is used to specify an alternate page to display if an uncaught error occurs.
ii. When isErrorPage is set to true, it indicates that the page is used as an error page.

b) Include Directive. <%@ include.. %>
c) Tag library directive <%@ taglib = url= "" prefix =""%>
Term
What is the difference between static and dynamic include?
Definition
The static include is the result of an include directive that occurs during page translation of the JSP life cycle. Dynamic include is the result of the standard action tag occuring in the body of the JSP. The two JSPs are loaded separately and are summed together at run time.
Term
What are the different ways of handling a session?
Definition
Cookies, Session and URL Rewriting
Term
What is the difference between XML and HTML?
Definition
XML describes the data. HTML displays the data.
Term
How would you write a message back to the browser via a servlet?
Definition
PrintWriter out = response.getWriter();

out.println("text goes here")
Supporting users have an ad free experience!