This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a JSP and a Java Bean (class). In this JSP I have some values that are already available to me via JSTL. In the Java Bean I would like to be able to access the "out" PrintWriter object to print out some html comments to the users.
So how do I include the Java Bean on the JSP page? If I use useBean, I can't pass the bean the "out" object (since setProperty only takes Strings). If I revert to scripting...I'll have this ugly combination of JSTL and scripting. Is there any other option?
P.S. With <c:set> you can pass anything you'd like to a property -- it's a common myth that beans only support string properties.
Joined: May 11, 2005
You seem (rightly) concerned about the design badness of mixing JSTL and scriplets, and yet you seem cavalier about emitting HTML from inside beans. Strange dichotomy.
I know this is a strange requirement, but we have some very complicated logic that is difficult and time consuming to trace. Every time we see this one scenario happening that we don't want...we find ourselves running query after query to debug and find out why it is happening. I thought it would be easier when certain conditions are met just show why they are met by printing out certain DB flag values in the comments.
Why do you feel the need to emit HTML from code? Do you have a good reason to not employ a custom tag file for such purposes?
We are using an ancient app server and we've seen performance issues from custom tags. I can't explain why but I would be willing to guess it has something to do with how old this app server is.
Perhaps a little more info on the scenario would help clarify...
I didn't design this...if it were up to me, all the logic would be done in a controller and the JSP would just have to display stuff. But...I inherited it like this...where the JSP is responsible for a lot of the business logic.
Can you give me an example of a setProperty where it is passing in an object?