• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recreating c:out

 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I like cut. I like it a lot. I like it's default functionality if the object is null. However, I would like to have a default character if the object is an empty string also. Here is some code:






the Problem that I'm running into is that whatever gets sent into the tag is like the following ${shirt.color}. So what gets set for value is "${shirt.color}" instead of "blue".

I'm also using

This may be something that was fixed in a newer version.
[ June 16, 2008: Message edited by: paul yule ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of JSP, and how do you have your deployment descriptor set up? See the JSP FAQ to make sure that your app is properly configured for JSP 2.0.
 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The web XML

I've used custom tags before. I was able to get simple ones working but I'm not sure if I can update too much without breaking a lot. Normally if i needed an object inside the tag I would do:


the problem being that I can't evaluate on the page because don't have an attribute name to search for because they could be passing in a property rather than an expected object.
[ June 16, 2008: Message edited by: paul yule ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I suspected, your problem is that you have your web app declared as a Servlets 2.3 app. This turns off the EL by default. If you are using a JSP 2.0 container, properly declaring you web app as Servlets 2.4 app will solve this.

This is covered in the JSP FAQ.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Under JSP 2.0, you should also be using the SimpleTag support rather than the classic tag support.
 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as with most things here, it's very outdated. Is changing it to 2.4 going to break anything? Or is it backwards compatible? My thoughts were that there was a way around this since cut is from what, 1.0? Otherwise, i just may have to do what you suggest.
[ June 16, 2008: Message edited by: paul yule ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The big difference is in where the EL is evaluated. In JSP 1.x with JSTL 1.0, the JSTL had to take care of evaluating EL expressions. Any custom actions you write in that environment must also do so. In JSP 2.0 with JSTL 1.1, the JSP engine takes care of that for you before the action (JSTL or your own) are invoked.
 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, my problem is that




[ June 16, 2008: Message edited by: paul yule ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you have to be running a container that supports Servlet 2.4 and JSP 2.0. Which is it? (Forum instructions say that you should include this information with your original post.)
 
Clay Embry
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just created my first custom tag yesterday and ran in to this same problem. There seems to be very little information about how this works for Servlet 2.3/JSP 1.2

After much searching and tearing my hair out I found this link. This method worked for me, but it's like a black box. I have no idea how it works.

http://www.informit.com/articles/article.aspx?p=30946&seqNum=9

The key is the code in Listing 2.29 in the article.
 
Paul Yule
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yar, this stuff that i'm using is way outdated and IBM doesn't even support the IDE anymore.

Thanks Clay and Bear for your responses...

What you posted though is what i posted in my OP. The problem with .evaluate() is it is requires an attribute to search for on the page IE


Is needed before I'm allowed to evaluate on the page. So if I just want to take

I can't, because the evaluate method requires a variable defined in one of the scopes. I can't .evaluate() without setting variables for everything I want to write to the page. So if I wanted to display 80 attributes for an object I'd have to go and <c:set> every single attribute.
[ June 20, 2008: Message edited by: paul yule ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!