File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Cookies example in HFSJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookies example in HFSJ" Watch "Cookies example in HFSJ" New topic

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. "" - servlet which adds a cookie and transfer the control to a jsp which again takes to another servlet named "".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


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.

Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2851

Can you access the result.jsp directly by typing it in the browser address bar?

|Asking Good Questions|
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
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.

So much trouble in the world -- Bob Marley
vinal sen
Ranch Hand

Joined: Dec 13, 2007
Posts: 37
this is my application file structure


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 sen
Ranch Hand

Joined: Dec 13, 2007
Posts: 37
I could not properly display the file structure.sorry.

under myapplication,I have


under WEB-INF, I have



thank you,Vinal
I agree. Here's the link:
subject: Cookies example in HFSJ
It's not a secret anymore!