i have read lots of threads that try to clarify the paths associated with a requestdispatcher. but the damn thing isnt yet clear. i have probelms even while running some sample applications of my own, which usee the requestdispatcher
but when i run my app, i see a blank page, or in other words, contents from the result.jsp arent displyed on the browser where should i place the result.jsp ?? Please mention propery the exact directory structure
where do i keep the "jsp" folder ? should i keep it as
myApp/WEB-INF/jsp/reult.jsp OR myApp/jsp/result.jsp ??
When you reply to my query.please dont bluff the typical lines from the spec- "relative to the context root" or "relative to current request
i want a dirctory structure for all the POSSIBLE paths that we can use in getRequestDispatcher(String path) i would be grateful if you give a explanation lik - "if the path is "...../..../....jsp" then place the jsp in "..../.../..." where .... is directory name.
the whole thing is f****ing me a lot, and i want to get a solid understaning of it in my mind.
"EVEN IF I AM TAKING CARE OF THE DIRECTORY STRUCTURE AND THE PATHS, WHAT COULB B THE REASON THAT I M NOT GETTING A BLANK PAGE AS TEH OUTPUT??"
please help out niranjan
SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ] Performance is a compulsion, not a option, if my existence is to be justified.
1) If the path inside the getRequestDispatcher(...) starts with a '/', it should be relative to the context root[your folder under webapps], which is "myApp/" for ur case, and the the path for the jsp is "myApp/jsp/result.jsp"
2) If the path inside the getRequestDispatcher(...) doesn't start with a '/', it is relative the CURRENT request[hard to explain without saying it...I would include an example]. Say now you are accessing ur app thru http://localhost:8080/myApp/redirect.do, the result page then should be contained in "myApp/jsp/result.jsp" [which is the same as Q1] However, if u are accessing it with http://localhost:8080/myApp/test1/redirect.do [assume u have another servlet mapping on another path], the container will then try to search if there is result.jsp under "myApp/test1/jsp/result.jsp"
3) For "/result.jsp", it should reside on "myApp/result.jsp"
4) Same as Q1
Hope u understand
SCJP 1.4 since 24 July 2004<br />
SCWCD 1.4 since 24 Jun 2006<br />
SCJD 1.4 since 12 July 2007<br />
SCEA Part 1 since 31 May 2009<br />
SCEA Part 2 Preparing<br />
SCEA Part 3 Preparing<br />
I think the simplest way to remember it is that Consider "/" as "myApp" Directory. So you can easily resolve the paths. Also remember that View components are always put under the context root of your web app(or in a directory under the context root) and not under WEB-INF.
I hope this will help
regards, Sarang Bharambe
SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!