If I'm understanding correctly, this is not a URL encoding problem.
Problem might be the file location.
When we do url encoding basically we apply these rules.
- The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
The special characters ".", "-", "*", and "_" remain the same.[/list]
- The space character " " is converted into a plus sign "+".
- All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte. The recommended encoding scheme to use is UTF-8. However, for compatibility reasons, if an encoding is not specified, then the default encoding of the platform is used.
For example using UTF-8 as the encoding scheme the string "The string ü@foo-bar" would get converted to "The+string+%C3%BC%40foo-bar" because in UTF-8 the character ü is encoded as two bytes C3 (hex) and BC (hex), and the character @ is encoded as one byte 40 (hex).
So i think you are encoding the url correctly.
is your corrent file( i mean where this jsp code is being running, and the newjsp.jsp are in same folder?
Do a dry run.
-
<%
-
/* For the time being let these statements be commented
-
String url="newjsp.jsp?name=vimal&id=0812573&NIC=vimal basdeo&f=nasha sahdjsa hk";
-
-
url=URLEncoder.encode(url,"UTF-8");
-
*/
-
out.println("<a href="http://localhost:8080/WebApplication1/newjsp.jsp?name=vimal&id=0812573&NIC=vimal basdeo&f=nasha sahdjsa hk"><img src='ajith-billa2.jpg' alt='Ajit'></a>");
-
-
%>
-
And check whether its working or not.