This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I was getting this error too, when i was working with this. I also heared from someone that it's better to use
This will hold good when u are sending the request parameters alone to the JSP.
Any way, i came across a difference in using both the methods
That is :
The servletRequest's getRequestDispatcher() can take a relative path while ServletContext's getRequestDispatcher() can not(can only take relative to the current context's root).
For example with ServletContext both -> request.getRequestDispatcher("./jsp/jsppage.jsp") - evaluated relative to the path of the request -> request.getRequestDispatcher("/jsp/jsppage.jsp") - evaluated relative to the root are all valid
with ServletContext only -> context.getRequestDispatcher("/jsp/jsppage.jsp") is valid but not context.getRequestDispatcher("./jsp/jsppage.jsp"). that is it can not evaluate a path other than context root.
But i would like to know the pros and cons of the methods....
Joined: Sep 08, 2004
Thanks, people..For now , I will use the ServletContext but hopefully some day I will know why request.getRequestDispacther did not work for me. Thanks for replying!
Joined: Aug 15, 2004
the error, you are gettin, looks like a compile time error. It doesn't mean that it didn't work, but its like why are you getting compile time error. wiered. [ September 23, 2004: Message edited by: adeel ansari ]