*
The moose likes JSP and the fly likes File generation in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "File generation in JSP" Watch "File generation in JSP" New topic
Author

File generation in JSP

Bilal Ali
Ranch Hand

Joined: Jun 14, 2007
Posts: 66
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

Joined: Jan 10, 2002
Posts: 60780
    
  65

%20 is the URL-encoded value of a space character. Where is the file name coming from?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
When you code the link from the button, make sure it is "/TESTFILE.IN" not "/TESTFILE.IN "


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Bilal Ali
Ranch Hand

Joined: Jun 14, 2007
Posts: 66
@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

Joined: Jun 14, 2007
Posts: 66
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

Joined: Jan 10, 2002
Posts: 60780
    
  65

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

Joined: Jun 14, 2007
Posts: 66
@Bear Bibeault
Thanks a lot , you have resolved my issue , actually the value being inserted in the database consisted of empty spaces.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: File generation in JSP
 
Similar Threads
basic query regarding the propogation of plugin-cfg.xml file
Restarting Websphere v5.0 Test Environment
Chapter 2 (HFSJ) notes , may be useful for anyone
Applet Gui is not updating inside JSP pages
How to get Tomcat to listen on port 80