This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookies example in HFSJ

 
vinal sen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why result.jsp is directly inside tomcat/webapps ? it should be somewhere under your application root directory.
 
vinal sen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai Sudhir!

Tried that also,did not work.Is there anything wrong with my jsp file.

Thanks
vinal
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you access the result.jsp directly by typing it in the browser address bar?
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vinal sen
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic