my dog learned polymorphism*
The moose likes JSP and the fly likes Nesting JSTL Tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Nesting JSTL Tags" Watch "Nesting JSTL Tags" New topic
Author

Nesting JSTL Tags

Samarth Kumar
Greenhorn

Joined: Mar 30, 2004
Posts: 12
Folks,

I'm new to the world of JSTL and am trying to nest two tags. I am not sure if this can be done.

This is what my code looks like,

<c:choose>
<c:when test = "${pdView.isFlag}" >
<c:choose>
<c:when test = "${pdView.isOnFormalWarning}" >N/A
</c:when>
<ctherwise>
<cut value = "${pdView.jobPostingDate}" />
</ctherwise>
</c:choose>
</c:when>
<ctherwise>
Data is not available
</ctherwise>
</c:choose>

Do let me know if this is possible. Thanks,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

What happened when you tried it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Samarth Kumar
Greenhorn

Joined: Mar 30, 2004
Posts: 12
I got a blank page, I guess the JSP did not compile.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

What did a View Source show?
Samarth Kumar
Greenhorn

Joined: Mar 30, 2004
Posts: 12
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

Yup, looks like something is failing. If you're not getting error messages when JSP translation fails, now is the time to stop and fix your setup so you don't waste time chasing down every little sytnax error.

P.S. The answer to the original question is: yes, you can nest tags as much as you want. Just be sure that everything is well-formed.
Samarth Kumar
Greenhorn

Joined: Mar 30, 2004
Posts: 12
I have been able to narrow down the failure to these lines of the JSP

<c:choose>
 <c:when test = "${pdView.isOnFormalWarning}" >N/A
 </c:when>
 <ctherwise>
  <cut value = "${pdView.jobPostingDate}" />
 </ctherwise>
</c:choose>

If I comment these lines out, then the JSP compiles and renders the other data from the tags. Maybe, I need to check the way I defined the variables in the bean.
[ May 31, 2006: Message edited by: Marilyn de Queiroz ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

The tags look fine on initial inspection, it's more likely that the EL expressions are throwing an error.

Again, I urge you to spend the time to find out why you aren't getting decent error messages on failure. You're wasting a lot of time guessing.

P.S. Clicking the 'disable smilies' box when posting will make your tags look a lot less surprised !
Samarth Kumar
Greenhorn

Joined: Mar 30, 2004
Posts: 12
bear,

that's true, i should focus on getting good error messages, is there a way to know where the error messages get logged to. my setup is websphere rad for development purposes running under websphere 5.1.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60732
    
  65

I'd post a topic in the websphere forum saying that you aren't getting error messages when there is a JSP failure.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
<c:when test = "${pdView.isOnFormalWarning}" >N/A

what is the method here? boolean getIsOnFormalWarning()?
or is it boolean isOnFormalWarning()?

Maybe the expression should be ${pdView.onFormalWarning}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nesting JSTL Tags
 
Similar Threads
The end tag "&lt;/c:choose" is unbalanced
calling javascript function from jstl
HOW: 'if'-like JSF conditions?
Can multiple conditions be checked using JSTL?
LogicGreaterThan tag