What is servlet?
Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company's order database.
What are the classes and interfaces for servlets?
There are two packages in servlets and they are javax.servlet and javax.servlet.http.
Javax.servlet contains:
Interfaces Classes
Servlet Generic Servlet
ServletRequest ServletInputStream
ServletResponse ServletOutputStream
ServletConfig ServletException
ServletContext UnavailableException
SingleThreadModel
Javax.servlet.http contains:
Interfaces Classes
HttpServletRequest Cookie
HttpServletResponse HttpServlet
HttpSession HttpSessionBindingEvent
HttpSessionContext HttpUtils
HttpSeesionBindingListener
What is the difference between an applet and a servlet?
a) Servlets are to servers what applets are to browsers.
b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.
what is the lifecycle of a servlet.
Each Servlet has the same life cycle:
a) A server loads and initializes the servlet by init () method.
b) The servlet handles zero or more client's requests through service( ) method.
c) The server removes the servlet through destroy() method.
What is the ServletConfig() and why are using ServletConfig ?
This interface is implemented by services in order to pass configuration information to a servlet when it is first loaded.A service writer implementing this interface must write methods
for the servlet to use to get its initialization parameters and the context in which it is running.
public interface ServletConfig
What is meant by the ServletContext() and use of the method ?
Ans: public interface ServletContext
The ServletContext interface gives servlets access to information about their environment ,and allows them to log significant events. Servlet writers decide what data to log. The interface is implemented by services, and used by servlets. Different virtual hosts should have different servlet
contexts.
What is use of parseQueryString ?
Parses a query string and builds a hashtable of key-value pairs, where the values are arrays
of strings. The query string should have the form of a string packaged by the GET or POST method.
(For example, it should have its key-value pairs delimited by ampersands (&) and its keys
separated from its values by equal signs (=).)
Note:
public static Hashtable parseQueryString(String s)
what are the types of servlets?
Genereic Servlets,HttpServlets.
what are the different methods in HttpServlet?
doGet(),doPost(),doHead,doDelete(),deTrace()
What is the difference between GET and POST?
a) doGet() method is used to get information, while doPost( ) method is used for posting information.
b) doGet() requests can't send large amount of information and is limited to 240-255 characters. However,
doPost( )requests passes all of its data, of unlimited length.
c) A doGet( ) request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.
No comments:
Post a Comment