Glimpse of Servlet (prerequisites Oops)
"Servlet ko samajhne ke liye Java mai oops ke concept ek thik thak pata hai to acha hai."
Servlet ka use kese karte hai (Level 1)
Servlet ko use karne ke liye hame class extends karna hota hai jese Generic and HttpServlet Class ye do class commonly use hote hai agar basic crud operation ka application banana hai to kafi hai
were mai internally inne hi sab ko extends ya implement kar rakha hai Servlet ko Servlet Interface hai aur interface ko direct implent nahi karte hai package mai jo class hai unko use karna hota hai
HttpServlet - jitne mai web terminology se related hai wo ye handle karega
Generic class - baki generic dekh lega bas basics mai itne hi use hone hote hai
Kuch aur classes aur interface for (Level 2)
ServletRequest Interface - provide client request information to a servlet such as content type, content length, parameter names and values, attributes etc.
Request Dispatcher - Forward and Include Other Servlet
SendDirect - redirect response to another resource, it may be servlet, jsp or html file.
ServletConfig Interface - Get Configure information from web.xml
ServletContext -
ServletContext
andServletConfig
are two interfaces that provide a way for servlets to access configuration information and resources provided by the web container.The main difference between
ServletContext
andServletConfig
is their scope and purpose.Attribute - in servlet is an object that can be set, get or removed from one of the following scopes: 1. request scope 2. session scope 3. application scope
The servlet programmer can pass informations from one servlet to another using attributes. It is just like passing object from one class to another so that we can reuse the same object again and again.
Session tracking Technique
1. cookie 2. Hidden Form Field 3. URL Rewriting 4. HttpSession
HttpSession Interface - container creates a session id for each user.The container uses this id to identify the particular user.An object of HttpSession can be used to perform two tasks:
bind objects
view and manipulate information about a session, such as the session identifier, creation time, and last accessed time.