• Post Reply Bookmark Topic Watch Topic
  • New Topic

generate URL, difference

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the JSP page, if we want to generate URL, we have two ways.

1.
url="/contextpath/a/b";

<%= url %>

2.
using JSTL.
<c:url value="="/contextpath/a/b" />

what is the difference ? which way is better ?

Thanks.
 
Darren Edwards
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One uses scripting the other is using JSTL (JSTL is the preferred choice for JSP pages). The JSTL version is also better because it takes care of session ids if the user does not support cookies.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only that but <c:url> will ensure that any query parameter added via <c:param> are properly encoded.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!