Cómo codificar una URL que quiero pasar como una cadena de consulta

I'm trying to send a URL as paramter of a query string like this example:

http://localhost.com/myapp.jsp?pathToFileURL=http://192.168.0.1/my_file.pdf

What I did is I used encode URL to encode the path before sending it to the server, problem is im getting a "400 Invalid URI: noSlash" because of this.

From what I read the problem is the tomcat security and that I should add a parameter to the tomcat startup

-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

But I can't modify the parameters of the tomcat, so is it possible to do it other way?

Muchas Gracias

preguntado el 09 de marzo de 12 a las 22:03

What code did you tried so far? URLEncoder.encode(queryString, "utf-8") debería hacer el truco. -

3 Respuestas

Tu puedes hacer URLSafebase64 encoding at the client side and URLSafebase64 decoding at the server side. Check Codificador de URL class for more details: http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html

You can test manually before coding using any of the online URL Encoder/Decoder. Just google for "URL Encoder/Decoder"

respondido 25 mar '14, 22:03

Complete stab in the dark but you could try escaping the slashes with backslashes or you could try replacing them with %2F which is the URL encoded version of forward slash.

Espero que esto ayude.

respondido 09 mar '12, 23:03

I already doing that like this : http%3a%2f%2f192.168.0.1%2fmedia but in this case the tomcat it's not accepting %2f for security reasons - Giancarlo Corzo

Base64 the URL then on the receiving end base64 decode to get the original URL without any alteration

respondido 09 mar '12, 23:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.