Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File generation in JSP

 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
We are working on java web application with jsp at front end , tomcat as web server and beans for business logic and calculations , oracle 9i is the backend db. We have provided a button on our page and when the user clicks this button a file is generated with the following name and path:

http://192.168.1.5/downloads/TESTFILE.IN

but while creating the file on the server "%20" is automatically appended at the end of file name and unexpectedly the name of file on tomcat becomes:

http://192.168.1.5/downloads/TESTFILE.IN%20

My question is that from where odes this %20 comes , is it a default behaviour of tomcat or what is the cause , while testing this application on my local PC the problems does not occur but when we deploy on the remote web server only than does the problem occurs.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64630
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
%20 is the URL-encoded value of a space character. Where is the file name coming from?
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you code the link from the button, make sure it is "/TESTFILE.IN" not "/TESTFILE.IN "
 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear Bibeault
The file name is coming from a database and I am also applying trim() method on it.

Duc Vo
I am applying trim() method on the file name from database so there is no question that the last space will be an empty space , still %20 is coming at the end.
 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please any one reply , I am badly stucked in this issue , any one please give some useful suggestion that how to resolve this issue.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64630
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are trimming after the space is converted to %20, that's not going to help.

Is the value valid while it's in the database, or is it wrong there? If it's ok in the DB, you need to follow the steps it takes to see where it's getting mangled.
 
Bilal Ali
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear Bibeault
Thanks a lot , you have resolved my issue , actually the value being inserted in the database consisted of empty spaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic