• Post Reply Bookmark Topic Watch Topic
  • New Topic

null value in request

 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • 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?
 
Jaime Garcia
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Let me ask a follow up. Why are there both getParameters and getAttributes? How are they different?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!