| Author |
Cookies example in HFSJ
|
vinal sen
Ranch Hand
Joined: Dec 13, 2007
Posts: 37
|
|
In that example there is 1. "form.html" in which we enter the user name and click submit 2. "cookietest.java" - servlet which adds a cookie and transfer the control to a jsp which again takes to another servlet named "checkcookie.java".in "checkcookie" we retrieve the cookie. The problem is in the cookietest,trying to use the request dispatcher.I had saved the "result.jsp" directly under tomcat/webapps when I use this code it gives me Null Pointer Exception or results in result.jsp not found. I checked the parameter name,cookie name and the location of the file.I am unable to locate the problem.Please help. Thank you very much.Vinal Note: replaced Cookie with Kookie to post this topic
|
 |
sudhir nim
Ranch Hand
Joined: Aug 29, 2007
Posts: 212
|
|
|
Why result.jsp is directly inside tomcat/webapps ? it should be somewhere under your application root directory.
|
[Servlet tutorial] [Servlet 3.0 Cook Book]
|
 |
vinal sen
Ranch Hand
Joined: Dec 13, 2007
Posts: 37
|
|
hai Sudhir! Tried that also,did not work.Is there anything wrong with my jsp file. Thanks vinal
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2552
|
|
|
Can you access the result.jsp directly by typing it in the browser address bar?
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
This "RequestDispatcher view=request.getRequestDispatcher("/result.jsp")" is being interpreted relative to the current context root. So, make sure your jsp is in the right place. As already suggested, try putting your jsp at the root of your wepapp.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
vinal sen
Ranch Hand
Joined: Dec 13, 2007
Posts: 37
|
|
this is my application file structure c:\ |_______apachetomcat |___webapps |_______myapplication |___form.html |___result.jsp |___WEB-INF |____web.xml |____classes |___com |___example |___myclasses 1.from myclasses,if I have to use RequestDispatcher what should be the path? RequestDispatcher rd=request.getRequestDispatcher("result.jsp"); gives me error. 2.Do I have to map jsp file in web.xml? Please help.Thanks in advance. Vinal
|
 |
vinal sen
Ranch Hand
Joined: Dec 13, 2007
Posts: 37
|
|
I could not properly display the file structure.sorry. under myapplication,I have result.jsp form.html WEB-INF under WEB-INF, I have classes ------- thank you,Vinal
|
 |
 |
|
|
subject: Cookies example in HFSJ
|
|
|