Link to home
Start Free TrialLog in
Avatar of noijet
noijet

asked on

Am I doing this JSP custom tags right ?...

Hi, I am new to JSP Custom Tags and I'd like to know if I am using it correctly.  I'd like to converting code#1 into code#2 (code provided below for reference) using JSP custom tags, am I doing it correctly or is there a better way?  

Any suggestions or tips would be greatly appreciated!

Thanks, noijet
***** code#1 (Inside a jsp)*****
<%
    if(loginBean.isDualLogin()) {
      %>

     ...Some HTML code....

else{
      %>
      ...Some other HTML code....
      <%
      }
    %>

***** code#2 (Inside a jsp) *** Is this correct ? *****
<control:conditional condition="user.isAdmin">
      ...Some HTML code....
</control:conditional>
<control:conditional condition="<%=(!user.isAdmin)%>">              
      ...Some other HTML code....
</control:conditional>

***** Java tag handler *****  
  public int doStartTag() throws JspException {
    if(condition) {
      return EVAL_BODY_INCLUDE;
    }  
    return SKIP_BODY;
  }
ASKER CERTIFIED SOLUTION
Avatar of jessegivy
jessegivy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noijet
noijet

ASKER

Hi jessegivy, thanks for your post, I am new to JSP custom tags, so currently I am practicing with it.  This kind of long, thanks in advance for your patience.   Basically, from the start, we only had the if statement (code#1) --> then we used a conditional custom tag (code#2) to replace the 'if' statement --> Now, we want to add an else clause (code#1)--> This is why I am trying to use code#2, but I'm just wondering if thats the way it is usually done in JSP custom tag code.

I think:
EVAL_BODY_INCLUDE: Means to evaluate the body
SKIP_BODY: Means to 'done', skip body evaluation.

Thanks so much,
noijet.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of noijet

ASKER

Thank you searlas.  So if I had to include that else condition to that "if" custom tag already existing, I would do it the way I stated above(code#2)?

Thanks so much,
noijet
Avatar of noijet

ASKER

Thank you both for your excellent comments and code !

Thanks again,
noijet.