aspose file tools*
The moose likes JSP and the fly likes Way to pass parameters to a bean in JSTL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Way to pass parameters to a bean in JSTL?" Watch "Way to pass parameters to a bean in JSTL?" New topic
Author

Way to pass parameters to a bean in JSTL?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm wondering if the only answer here is for me to write a tag library but I wanted to float this to the group. I'm trying to convert scriptlets to JSTL. I have this scriptlet ...



"appInterface" is a bean I define earlier on my page. Is there a way I can rewrite the above in JSTL and pass the parameters to the method?

This scriptlet block is part of a larger block that looks like this ...




Yup, it's a mess. Anyway grateful for your thoughts on the question above. Thanks, - Dave
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

You cannot pass parameters. And if your class has methods such as that, it's not a "bean" by definition.

The real answer is to rethink how data is being passed to the page, and to change the data classes made available to the JSP to actually be beans. But that may be a refactor that you are not prepared to do.

It's very difficult to convert a JSP from scriptlets to JSTL/EL using a line-by-line approach because with scriptlets so many bad practices are possible on the page (which is why scriptlets are discredited), so a line-by-line replacement is usually not possible.

If you just want to replace that one line without refactoring, you'll either need to create a custom tag or an EL function.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Way to pass parameters to a bean in JSTL?