0

In a Servlet, using the code:

String requestURL = request.getRequestURL().toString();

I receive the URL: http://localhost:8080/TV/admin/adminView.do

How can I change this link dynamically?

The final link should be: http://localhost:8080/TV/file.txt (i.e. http:// + server + client + file.txt).

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Dan
  • 393
  • 1
  • 4
  • 19
  • 1
    That's the request URL. You can't modify that. Even if you could, it wouldn't do anything. Are you asking how to do a redirect? – Kayaman Apr 15 '15 at 10:45
  • I need to find out if exists the file (file.txt) on this server and client. – Dan Apr 15 '15 at 11:46
  • I have no idea what you're trying to achieve. – Kayaman Apr 15 '15 at 11:48
  • When the file.txt exists on this server and with this client (server and client can be different) I want to display the link to view this file, but only if the file exists. Some clients do not have such file, for example the link http://ctva/stag/file.txt - works fine, but the link http://ctvb/graphs/file.txt - does not exist. – Dan Apr 15 '15 at 11:55
  • So the client can "see the link" only if he has it and the server has it? What on earth are you trying to do? In any case you're way off. – Kayaman Apr 15 '15 at 12:46

1 Answers1

0

You have to take a look at:

How to use a servlet filter in Java to change an incoming servlet request url?

or

how to change the requestURL using filter or servlet

bye

Community
  • 1
  • 1
gaetanoM
  • 41,594
  • 6
  • 42
  • 61