File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

Way to pass parameters to a bean in JSTL?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436

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

Joined: Jan 10, 2002
Posts: 63837

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Way to pass parameters to a bean in JSTL?
It's not a secret anymore!