| Author |
jstl c:url tag doubt ?
|
gurpeet singh
Ranch Hand
Joined: Apr 04, 2012
Posts: 868
|
|
following is a question from enthuware ocewcd 6 mock exam ?
Which of the following code correctly performs URL rewriting ?
1.) <a href="<c:url value='/cart.jsp?userid='ramesh'/>">View Cart</a>
2.) <a href="<c:url value='/cart.jsp' userid='ramesh'/>">View Cart</a>
3.) <a href="<c:url value='/cart.jsp' attr='userid' value='ramesh'/>">View Cart</a>
4.)<a href="<c:url value='/cart.jsp'>
<c:param name='userid' value='ramesh'/>
</c:url>">View Cart</a
the correct answer is option 4. why is the first option NOT correct?
can't we pass request parameters directly in the value attribute of c:url tag ? is it mandatory to use c:param tag jstl tag?
p.s. - i have posted this question in the enthuware forum also so that i can get a quick reply since i have my D-day for the exam tomorrow. i have searched google but couldnt find any answer
thanks and regards
Gurpreet
|
OCPJP 6(100 %) OCEWCD 6(91 %)
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1041
|
|
Hi Gurpeet,
I am not sure whether you typed it over correctly but I would say in the first option there is a quotation mark ( ' ) too much at the beginning of ramesh
Regards,
Frits
|
 |
gurpeet singh
Ranch Hand
Joined: Apr 04, 2012
Posts: 868
|
|
Frits Walraven wrote:Hi Gurpeet,
I am not sure whether you typed it over correctly but I would say in the first option there is a quotation mark ( ' ) too much at the beginning of ramesh
Regards,
Frits
i checked the question and yes there is a ( ' ) at the beginning of ramesh. i think it is a typo. lets remove it. will then it be a correct answer ??
want to know that do we need c:param to pass request parameters ? is it mandatory ?
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1041
|
|
lets remove it. will then it be a correct answer ??
Yes, then it will be ok
from the jstl specs
Syntax 1: Without body content
<c:url value="value" [context="context"][var="varName"] [scope="{page|request|session|application}"]/>
Syntax 2: With body content to specify query string parameters
<c:url value="value" [context="context"][var="varName"] [scope="{page|request|session|application}"]>
<c:param> subtags
</c:url>
p.s. - i have posted this question in the enthuware forum also so that i can get a quick reply since i have my D-day for the exam tomorrow. i have searched google but couldnt find any answer
p.s. Good luck tomorrow!
Regards,
Frits
|
 |
gurpeet singh
Ranch Hand
Joined: Apr 04, 2012
Posts: 868
|
|
|
Thanks Fritz
|
 |
 |
|
|
subject: jstl c:url tag doubt ?
|
|
|