This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 1512
  • 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
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic