File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Design Question JSTL or Scriptlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Design Question JSTL or Scriptlet" Watch "Design Question JSTL or Scriptlet" New topic
Author

Design Question JSTL or Scriptlet

Scott Maclary
Ranch Hand

Joined: May 11, 2005
Posts: 34
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?

Thanks,
Scott
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

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.

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?

Perhaps a little more info on the scenario would help clarify...
[ September 14, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

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.
Scott Maclary
Ranch Hand

Joined: May 11, 2005
Posts: 34
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

... all the logic would be done in a controller and the JSP would just have to display stuff.
I like you so much.

We are using an ancient app server ...
It can't be too ancient if it supports JSP 2.0. What are you using?

Can you give me an example of a setProperty where it is passing in an object?
setProperty is archives.



P.S. setProperty is still part of JSP, but I haven't used in in eons in lieue of <c:set>
[ September 14, 2007: Message edited by: Bear Bibeault ]
 
 
subject: Design Question JSTL or Scriptlet