• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cookies example in HFSJ

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai Sudhir!

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

Thanks
vinal
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you access the result.jsp directly by typing it in the browser address bar?
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic