Hi,
Can we use URL Encode in JSP file to remove special characteres such as %20 (equivalent to blank space), which are the part of the HTTP URL.
I guess similar thing is used in ASP, do we have something like that in JSP too.
Thanks
Nitu
-
URL Encode (5 messages)
- Posted by: Nitu Singh
- Posted on: May 29 2001 06:09 EDT
Threaded Messages (5)
- URL Encode by Andy Nguyen on May 29 2001 09:42 EDT
- URL Encode by Nitu Singh on May 30 2001 02:10 EDT
-
URL Encode by Andy Nguyen on May 30 2001 09:47 EDT
- URL Encode by Nitu Singh on May 31 2001 01:25 EDT
-
URL Encode by Andy Nguyen on May 30 2001 09:47 EDT
- URL Encode by Nitu Singh on May 30 2001 02:10 EDT
- URL Encode by Deepak Yinti on May 29 2001 09:43 EDT
-
URL Encode[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: May 29 2001 09:42 EDT
- in response to Nitu Singh
Take a look at java.net.URLDecoder and java.net.URLEncoder. I think what you want is URLDecoder.
Andy -
URL Encode[ Go to top ]
- Posted by: Nitu Singh
- Posted on: May 30 2001 02:10 EDT
- in response to Andy Nguyen
Thanks,
but still my problem remains the same.
let me explain u what exactly i want to do:
there is a file name with spaces, for example abc 123.txt,
now i want to display this file in the browser in a separate window. i am using javascript window.open(), where i am passing this file name. So what happens is the space in abc 123.txt is getting converted to abc%20123.txt, which is not existing and i am getting the error as "FILE NOT FOUND".
I hope i have made my problem quite clear. It would be great help if u could suggest some thing. I am using JSP and weblogic server.
Thank you very much
nitu -
URL Encode[ Go to top ]
- Posted by: Andy Nguyen
- Posted on: May 30 2001 09:47 EDT
- in response to Nitu Singh
I'm not sure how you're passing the file name to the JSP, but somehow you have to isolate the file name in a String variable. Once you do that, just use java.net.URLDecoder.decode(filename).
e.g.
(assuming file name is being passed as a request parameter, i.e. http://myserver/foo.jsp?filename=abc%20123.txt)
In your JSP:
<%@ page import="java.net.*" %>
<%
...
String encodedFilename = request.getParameter("filename"); // isolate the filename in a variable
String decodedFilename = URLDecoder.decode(encodedFilename);
...
%>
I would also suggest that you use the absolute path to access the file.
Andy -
URL Encode[ Go to top ]
- Posted by: Nitu Singh
- Posted on: May 31 2001 01:25 EDT
- in response to Andy Nguyen
Thanks a lot Andy,
Some how i am able to solve the problem now. Thanks for the help.
nitu -
URL Encode[ Go to top ]
- Posted by: Deepak Yinti
- Posted on: May 29 2001 09:43 EDT
- in response to Nitu Singh
u can go to JAVA API and look for Encode , Yes u can encode the path of URL