• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

jstl c:url tag doubt ?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Fritz
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic