aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jstl c:url tag doubt ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jstl c:url tag doubt ?" Watch "jstl c:url tag doubt ?" New topic
Author

jstl c:url tag doubt ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

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
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

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: 924
    
    1

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
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

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: 924
    
    1

Thanks Fritz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jstl c:url tag doubt ?