aspose file tools*
The moose likes JSP and the fly likes Unable to pass parameters to included url Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to pass parameters to included url" Watch "Unable to pass parameters to included url" New topic
Author

Unable to pass parameters to included url

Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 81
I am trying to pass a request parameter to a url that is included in a jsp with a jsp:include tag. I have tried



and




I also tried



and



I put a breakpoint in the method that is mapped to "/myUrl" and each time the value of myParam is null. I examined the requestURL and found that it was the URL which returned the jsp which contains this code and the query string was null. Can someone tell me what I am or might be doing wrong here?

Thanks,
Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Looks OK to me, but I never do it this way so I might just be off-base.

Rather than an include, I'd define a tag file or custom tag so that the value could be explicitly specified as a tag attribute. That way, it can also be something other than a string.

If, for some reason, I didn't want to do that, I'd pass the data as a request-scoped scoped variable. Params would be my last choice.

Can you include an SSCCE? If so, I'll see if I can put aside some time to give it a whirl on this end


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Dennett
Ranch Hand

Joined: Dec 07, 2010
Posts: 81
I decided to punt and use a request attribute. Thanks anyway.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Glad that's working for you. I think that's a better approach than a parameter, as it's not necessary to serialize the data to string. But thing I don't like about either of the param or scoped variable approach is that they're implicit and there's no way to force the value to be set or to type check.

With the tag approach, a required attribute to the tag can explicitly enforce that a value be passed, and of the expected type.
 
 
subject: Unable to pass parameters to included url