How do i do if-else condition in Struts ?

G

gk

How do i do if-else condition in Struts ?

logic:equal does not do it . how struts tag could be used in the JSP
page for an if-else condition ?

how to do it ?

Can anybody provide an example ?
 
A

Aj-India

Example:

if(age == 18) {
//some action
}
else {
//some other action
}

In Struts:
<logic:equal name="age" value="18">
<!-- some action -->
</logic:equal>
<logic:notEqual name="age" value="18">
<!-- some other action -->
</logic:notEqual>

Cheers,
Aj
 
L

Luke Webber

Aj-India said:
Example:

if(age == 18) {
//some action
}
else {
//some other action
}

In Struts:
<logic:equal name="age" value="18">
<!-- some action -->
</logic:equal>
<logic:notEqual name="age" value="18">
<!-- some other action -->
</logic:notEqual>

Holy crap. Why do they even bother?

I'm sorry, it's not your fault, but why on Earth would anybody bother
using taglibs for this sort of thing when it makes the whole thing so
much more obscure? Scriptlets aren't something to be ashamed of - they
work well, they're efficient, and they're perfectly readable to anybody
who knows Java.

Sorry to vent, but I really, really, REALLY dislike Struts.

Luke
 
J

James McGill

Holy crap. Why do they even bother?

I'm sorry, it's not your fault, but why on Earth would anybody bother
using taglibs for this sort of thing when it makes the whole thing so
much more obscure?

Whenever I see something like this, I'm praying that it's some kind of
auto-generated thing, and that the input to the generator is simpler
than the output.

Clearly there is a type of person that enjoys declarative programming
syntax using XML constructs, and there are lots of that type out there,
but I've never been one of them, and I hope I don't have to become
one...
 
S

Steve Sobol

Luke said:
I'm sorry, it's not your fault, but why on Earth would anybody bother
using taglibs for this sort of thing when it makes the whole thing so
much more obscure? Scriptlets aren't something to be ashamed of - they
work well, they're efficient, and they're perfectly readable to anybody
who knows Java.
Sorry to vent, but I really, really, REALLY dislike Struts.

It's not a taglib issue, it's a Struts issue. I like Struts mostly, and I
use Struts, but the lack of an "else" clause *is* just stupid.
 
L

Luke Webber

Steve said:
It's not a taglib issue, it's a Struts issue. I like Struts mostly, and I
use Struts, but the lack of an "else" clause *is* just stupid.

But again, why bother? For something that is so readily available via
scriptlets? It just leads to a splintering of standards so that I can't
read your code, because you employ a taglib that I don't know. Struts is
the major player, but there are other such. I honestly fail to see the
need for them.

I employ my own custom Javabeans quite frequently, but of taglibs I have
none, and I plan to keep it that way.

Luke
 
Joined
Apr 10, 2007
Messages
3
Reaction score
0
doubts

hai
can tell me how to check the if else for a java beans
ie i have a class called EmployeeLoginForm which has a varaible called roleName

how to check using struts the following condition

if EmployeeLoginForm.roleName==Trainee or Engineer or Manager

please tell me the code using <logic:equal> to check the bean class variables
 
Joined
Apr 10, 2007
Messages
3
Reaction score
0
doubts in <logic> tag

hai
<%@ taglib uri="WEB-INF/struts-logic.tld" prefix="empLogic %>
<empLogic:equal property="roleName" name="EmployeeHomePageFormBean" value="trainee" >
<empHtml:link href="/Trainee.jsp"> Trainee </empHtml:link>
</empLogic:equal>

when the above code is executed it says " equal symbol expected"

here EmployeeHomePageFormBean is the ActtionForm bean/class , roleName -is a varaible , it has both get and set methods

please tell me how to check conditions for java beans varaible
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top