tags:

views:

27

answers:

1

Using JSP, how can I put an active URL in a textbox?

A: 

Well there are 2 ways [server side and client side]:

in JSP you can do something like this to retrieve the URL that is currently loaded:

<input type="text" id="currentURL" value="<%= request.getRequestURI() %> " />

you can also try to use request.getRequestURL() depending on what you need.

More info on this page: http://www.theserverside.com/discussions/thread.tss?thread_id=5651

You can also retrieve the same info by using JavaScript:

var currentURL = document.location;

and then assign it to the input field you require.

dawez
I would have upvoted if you didn't use the old-fashioned and discouraged *scriptlets*. Besides, the OP's question is still unclear and ambiguous, so it's just hunting in the dark for the correct answer. I myself interpreted it more as "a clickable link inside an `<input type="text">` or `<textarea>` element", but I'd rather wait until the OP has cleared up his question as per the comment.
BalusC
Hey BalusC, avoiding scriptlets would be something like:<c:out value="${requestContext.requestUri}"/>But this is Spring specified, probably there is something similar for other frameworks. IMHO "active URL" means the one on the URL bar [i.e. the current URL of the page] Better to wait a proper explanation of the request.
dawez