• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To open file by passing file path which having spaces is showing path wrong.

 
SaiManasa Dasari
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
here is my code to open file by clicking on filename link in jsp using javascript.



javascript function is::;



filepath is../home/infrastructure/WEB-INF/classes/attachments_email/4091/Upload Document/Consolidate.pdf
But problem is in filepath spaces are there at "Upload Document".when clicking on this link the path showing like
"/home/infrastructure/WEB-INF/classes/attachments_email/4091/Upload%20Document/Consolidate.pdf" in firefox and chromium browsers..

please can anyone help me on this and i want only to open file directly by clicking on filename.is this code works for that or need any changes?please help me.

THANKS...
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai,

You need to encode your string. there is a function escape and unescape in Java script which will you can utilize for encoding the path.

Link for the reference.
http://www.w3schools.com/jsref/jsref_unescape.asp

Regards
Jatan

 
SaiManasa Dasari
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for Your replies..I tried unescape() as

window.open(unescape(filepath)).

But still it tring to open the path like replacing space with %20 when clicking on the link..please can anyone help me.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
%20 is the correct encoding for a space character.
 
SaiManasa Dasari
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Your reply.

But while opening it is showing an error like http status404 error as the requested resource not available.but my pdf file iss there in that specified path..please reply me what to do to get open that file by clicking on that link.please help me.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the actual URL that is being used and what is the exact file path and file name for the PDF? Not giving us the details will simply result in a delay in getting an answer.
 
SaiManasa Dasari
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Your Replies..I got solution for my problem using servlets and jsp posting in javaranch forums....

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic