What is the difference between the getRequestDispatcher(String
path) ServletRequest interface and ServletContext interface?
The getRequestDispatcher(String path) method of ServletRequest
interface accepts parameter the path to the resource to be included or
forwarded to, which can be relative to the request of the calling servlet. If the path begins with a "/" it is
interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of ServletContext
interface cannot accepts relative paths. All path must sart
with a "/" and are interpreted as relative to curent
context root. If the resource is not available, or if the server has not
implemented a RequestDispatcher object for that type
of resource, getRequestDispatcher will return null.
Your servlet should be prepared to deal with this
condition.
What is the use of ServletContext ?
Using ServletContext, We can access data
from its environment. Servlet context is common to
all Servlets so all Servlets
share the information through ServeltContext.
Is there any way to generate PDF'S dynamically in servlets?
We need to use iText. A
open source library for java. Please refer sourceforge
site for sample servlet examples.
What is the difference between using getSession(true) and getSession(false) methods?
getSession(true) - This method will check whether already a session is
existing for the user. If a session is existing, it will return that session
object, Otherwise it will create new session object
and return taht object.
getSession(false)
- This method will check existence of session. If session exists, then it
returns the reference of that session object, if not, this methods will return
null.
Advertisement
No comments:
Post a Comment