aspose file tools*
The moose likes JSP and the fly likes request.getParameter retuning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "request.getParameter retuning null" Watch "request.getParameter retuning null" New topic
Author

request.getParameter retuning null

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
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

Joined: Sep 29, 2008
Posts: 12617

Nothing to do with ORM; moving to JSP.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jul 11, 2008
Posts: 48
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 .


SCJP 1.5,SCWCD 1.5
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
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

Joined: Sep 29, 2008
Posts: 12617

: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

Joined: Feb 19, 2009
Posts: 162

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

Joined: Sep 29, 2008
Posts: 12617

The same thing happens if you just cut-and-paste the URL into the browser?
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Even if I paste it.

Something weird happened. I moved this



before this and it works



Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

:shock:

Yeah, that'd fall under "weird"; I sure can't reproduce anything like that.
adil qureshi
Ranch Hand

Joined: Jul 11, 2008
Posts: 48
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

Joined: Sep 29, 2008
Posts: 12617

And POST parameters can't be?
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParameter retuning null