0

From some other posts, I was able to get the current URI via:

<%= request.getRequestURL() %>

However the following doesn't work:

<%! String foo = request.getRequestURL(); %>

I'm curious why the above doesn't work, and how to assign the current URI to a string.

James Oravec
  • 19,579
  • 27
  • 94
  • 160

2 Answers2

2

Per the javadocs, getRequestURL() returns a StringBuffer, not a String.

Try this instead:

String foo = request.getRequestURL().toString();
rmlan
  • 4,387
  • 2
  • 21
  • 28
0

Shortly after posting this, I found out how to make it work. The following code work:

<%
    StringBuffer foo = request.getRequestURL();
%>

I need to do some research to see what the difference between <% and <%! is.

James Oravec
  • 19,579
  • 27
  • 94
  • 160