Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp Expression tag inside <a href> html tag

 
pratapsiva sivakumar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%
String url =response.encodeURL("hello2.jsp");
%>

\'> >hello2.jsp --- this line in not working.I want to know the syntax of giving jsp Expression tag inside html tag.Please help
 
Anjali Raman
Ranch Hand
Posts: 57
posted 6 years ago
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...
This is the code snippet. Hope this answers your questions

hello1.jsp
<%@ page session=\"true\" %>
<%
String url =response.encodeURL("hello2.jsp");
%>
\'>hello2.jsp

~Anjali
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The syntax of an expression is <%= expression %>. If you want to put the url variable in the anchor tag's href attribute, you'll need to do this

 
Anjali Raman
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry some problem with the way I was putting the code. My answer was the same as Ankit.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A more modern approach would be to use the <c:url> JSP action.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anjali Raman wrote:Sorry some problem with the way I was putting the code. My answer was the same as Ankit.


You can disable HTML in your messages. There is a checkbox in the options area that says "Disable HTML in this message". Checking that solves the problem...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic