HWZ Forums

Login Register FAQ Mark Forums Read

new help with JSTL

Reply
 
LinkBack Thread Tools
Old 24-06-2010, 08:45 PM   #1
Senior Member
 
Join Date: Mar 2009
Posts: 1,329
new help with JSTL

<c:if test="${not empty param.gender &&
fn:contains(param.gender,'Female')}">


i would like to ask if it's possible instead of the 'female' am i able to put in a param.
cause i tried replace the 'female' with another param like param.sex but failed.

need some help from the pros.
thanks
__________________
i will be happy, i must be!
affinityseven is offline   Reply With Quote
Old 25-06-2010, 12:52 AM   #2
Junior Member
 
Join Date: Jun 2010
Posts: 50
param.gender is from the posted data. you will need to add a hidden input with ID=sex and value=female.
how about use taglib/tld instead of jstl.
DonnieKun is offline   Reply With Quote
Old 25-06-2010, 01:22 PM   #3
Senior Member
 
Join Date: Mar 2009
Posts: 1,329
it's cause i need to use jstl to validate the posted data

so forexample the posted data is Login : 1234
e-mail :1234@hotmail.com



i need to pop and error msg. so i was thinking is there any method to using jstl to validate it.
__________________
i will be happy, i must be!
affinityseven is offline   Reply With Quote
Old 25-06-2010, 01:46 PM   #4
Junior Member
 
Join Date: Jun 2010
Posts: 50
dont think non-custom JSTL tag is capable of validation.
pop error msg is javascript jobs.
server-side validation suggest you use doFilter (the Interceptor Pattern similar to Strut) to separate "validation of input" logic from core business logic.
DonnieKun is offline   Reply With Quote
Old 25-06-2010, 01:53 PM   #5
Junior Member
 
Join Date: Jun 2010
Posts: 50
anyway if your way suits you,

<c:if test="${not empty param.gender &&
fn:contains(param.gender,param.sex)}">

doesn't work.

Unless you have a hidden input
<input name="sex" id="sex" value="female" type="hidden" />

You can do:

String Sex = "female"; request.setAttribute("sex",Sex); <c:if test="${not empty param.gender && fn:contains(param.gender,sex)}">
Does this answer you? If you are not satisfied, feel free to illustrate your desired output, I can try to figure out your problem for you

Last edited by DonnieKun; 25-06-2010 at 01:57 PM..
DonnieKun is offline   Reply With Quote
Old 25-06-2010, 06:25 PM   #6
Senior Member
 
Join Date: Mar 2009
Posts: 1,329
anyway if your way suits you,

<c:if test="${not empty param.gender &&
fn:contains(param.gender,param.sex)}">

doesn't work.

Unless you have a hidden input
<input name="sex" id="sex" value="female" type="hidden" />

You can do:

String Sex = "female"; request.setAttribute("sex",Sex); <c:if test="${not empty param.gender && fn:contains(param.gender,sex)}">
Does this answer you? If you are not satisfied, feel free to illustrate your desired output, I can try to figure out your problem for you
thanks for ur help.

so my problem is:

information : user have to fill up a registration page( which i did in html and included it in my jsp page) the login id and e-mail must be unique( which also means that if the login ID is 123 the e-mail cant be 123@blah.com)

the codes below is how i authenticate it (which fails to do so):
<c:if test="${(!fn:contains(param.email,'@') || !fn:contains(param.email,'.')) ||fn:contains(param.email,'param.login') && param.email!=''}"> <c:set var="output" value="${output}Email should be a valid one\n"/> </c:if>
so i actually need help to know how am i able to use param.login to validate it.
thanks
__________________
i will be happy, i must be!
affinityseven is offline   Reply With Quote
Old 25-06-2010, 06:44 PM   #7
Junior Member
 
Join Date: Jun 2010
Posts: 50
param.login is a variable, shouldnt put it in quotes.
DonnieKun is offline   Reply With Quote
Old 26-06-2010, 01:20 AM   #8
Senior Member
 
Join Date: Mar 2009
Posts: 1,329
i tried removing the quotes it still doesnt work :/
__________________
i will be happy, i must be!
affinityseven is offline   Reply With Quote
Old 26-06-2010, 01:24 AM   #9
Senior Member
 
Join Date: Mar 2009
Posts: 1,329
ok i solved it. thanks for the help DonnieKun.
it was my brackets error and the quotes.
once again thanks alot
__________________
i will be happy, i must be!
affinityseven is offline   Reply With Quote
Reply
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ. Forum members and moderators are responsible for their own posts.

Please refer to our Terms of Service for more information.


Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On