• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getParameter retuning null

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a url "summary.jsp?day=17&month=05&year=2010".
When I use this in summary.jsp it returns null for date, month and year.


I am able to get user without any problem.

I tried using request.getAttribute(). Still no results.

Please help !

Thanks

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing to do with ORM; moving to JSP.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it obviously won't work with getAttribute. I'd have to know more to believe that it didn't work with getParameter, though.
 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin Howard wrote:Hi All,

I have a url "summary.jsp?day=17&month=05&year=2010".
When I use this in summary.jsp it returns null for date, month and year.


I am able to get user without any problem.

I tried using request.getAttribute(). Still no results.

Please help !

Thanks



see first of all typecasting to string is not required at all in date , month and year since getParameter already returns string.
Secondly getAttribute wont work since you are not setting it any where .
Now can you tell the exact scenario , how you are hitting the URL are you using some servlet in between or directly hitting the URL .
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.
@Adil
There is no servlet in between. It is a url to the jsp directly.

I have used the apache file upload library in another jsp. But not in the jsp I am talking about.
I do not have enctype="multipart/form-data" in this jsp.

I have given below the two jsps in question.



JSP trying to get the values


Thanks




 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:shock:

In any case:That's going to set an attribute in the *current* request, not a new one.That's a weird id; not really contextually relevant.Is this the code that creates the URL? And it goes directly to the following JSP?

Are you saying they're null because you tried to display them, or because the query isn't returning anything, or some other reason?
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Please ignore that, some random tests.

I use the values in the query. Generated exceptions.
So I tried printing it. Prints the value as null in the logs.

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same thing happens if you just cut-and-paste the URL into the browser?
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if I paste it.

Something weird happened. I moved this



before this and it works



Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:shock:

Yeah, that'd fall under "weird"; I sure can't reproduce anything like that.
 
adil qureshi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi justin i will like to suggest a change since your issue got resolved that since you are passing the values in URL they can be changed any time externally ,i better feel that you must post the values instead of sending them in URL.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And POST parameters can't be?
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a list of links (dates on which the user clicks on)
Depending on the link selected the date changes.

Thanks for the suggestions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic