1.when should one use a servlet or JSP in a project?
I believe this is mostly a design design. JSP was introduced to separate presentation from business logic and to support dynamic web content. Usually, one should avoid too much of processing in JSPs and focus on content presentation although JSPs do support complex processing. Servlets are best suited for complex processing, and as filters and controllers (wrt MVC framework).
For the second question, you will readily find the answer if you go through the J2EE API Docs pages for ServletContext -> getRequestDispatcher(String path) method and ServletRequest->getRequestDispatcher(String path) Method.
I am pasting a few lines from both pages here for your ready reference..
2. what is difference between the calling requestdispatcher from request object and servletContext object?
From ServletContext Page:
The pathname must begin with a "/" and is interpreted as relative to the current context root.
From ServletRequest Page:
The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. [ August 03, 2005: Message edited by: Ritesh Agrawal ]
Ritesh<br /> <br />SCJP 1.4<br />IBM Test 340<br />IBM AIX V4.0 Certified Professional<br /> <br />Right actions for the future are the best apologies for wrong ones in the past.<br />- Tyron Edwards
posted 15 years ago
You answered my both questions. I really appreciate and thankyou for these answers.
Thanks Manish Jain SCJP1.4
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!