• 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

null value in request

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an action class in struts with the following code:

The numOfSsns variable is getting populated fine. Anyhow the forward gets moved on to a jsp that has the following code:

I am always getting a null value in the request, so the if statement is failing. What am I not getting right here?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are using:
request.setAttribute("numOfSsns",numOfSsns);
then forward a jsp and:
request.getParameter("numOfSsns");

getParameter will try to find it from a GET or POST method. You need to retrive it with getAttribute("numOfSsns"); not getParameter
Hope this helps.
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh! You da man! Thanks for the effort.
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me ask a follow up. Why are there both getParameters and getAttributes? How are they different?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parameters are read-only and represent the information sent from the client.
Attributes are a place for you maintain your own information in the request context.
Parameters are slightly different to the description given above since you can also define them when using the forward/include JSP tags, but as far as that JSP is concerned they are read-only.
Dave.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic