• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

URLEncoding

 
rdhinesh kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my J2EE application i have uploaded one MS word file
(Student Marklist March2007.doc)

while trying to download this word file am getting the following URL in the addressbar and statusbar

http://localhost/NewsUpdateFileCount.fms?fileId=244&
fileName=Student+Marklist+March2007.doc&
MODULE_NAME=NEWS_UPDATE_FOLDER&&newsUpdateId=60

But, i need the actual ms word file name should not change in the URL.

the URL should be like :

http://localhost/NewsUpdateFileCount.fms?fileId=244&
fileName=Student Marklist Mach2007.doc&
MODULE_NAME=NEWS_UPDATE_FOLDER&&newsUpdateId=60

In servlet all "spaces" are replaced with "+"

Please any one suggest me to solve this problem.

Regards
Dhinesh kumar R
 
Quintin Stephenson
Ranch Hand
Posts: 44
1
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
URLs may not have spaces in them. If you want a space in the URL it must be encoded. The + symbol is used to replace a space when encoding a URL. There are various websites that will help with URL encoding/decoding. If when you have extracted the value from the URL still contains the encoded characters you will have to decode it yourself. You could use the static decode method supplied in the java.net.URLDecoder class. The API found (http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLDecoder.html) states it will decode the + back to a space. There is also a matching encoding class and static method. The API can be found at http://java.sun.com/j2se/1.3/docs/api/java/net/URLEncoder.html

Hope this helps.
Q
[ April 05, 2007: Message edited by: Quintin Stephenson ]
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic