User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 426,809 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,886 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1021 | Replies: 3
Reply
Join Date: Dec 2007
Posts: 11
Reputation: shweta797 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shweta797 shweta797 is offline Offline
Newbie Poster

pass variable with space

  #1  
Dec 31st, 2007
Dear sir
In my project i have to pass variables when a user click on the link i.e there is full address
of a client which is getting from a table,when user click on this link all information is displayed,but the problem is if there is a space in the address as(united state) variables,only null value is displayed.
Please help
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 35
Reputation: mellamokb is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
mellamokb mellamokb is offline Offline
Light Poster

Re: pass variable with space

  #2  
Jan 3rd, 2008
Spaces are not acceptible Url characters. Use the Url equivalent, %20, whenever you need a space in the information transferred to get the best results. Or better yet, use a built-in Url Encoding method, like URLEncoder.encode(), to encode the entire Url before it is processed and take care of all non-Url-acceptible characters.

~ mellamokb
Reply With Quote  
Join Date: Dec 2007
Posts: 11
Reputation: shweta797 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shweta797 shweta797 is offline Offline
Newbie Poster

Re: pass variable with space

  #3  
Jan 7th, 2008
Thanks for the reply,but my problem is i m getting value from table as given in the code below
out.println(" <TD style=\"font-family:Verdana; font-size:11px; font-style:normal; font-weight:normal; vertical-align:middle; color:#3366FF;\"align=\"center\"><a href=report.jsp?address="+rs.getString("address")+">"+rs.getString("address") +"</a></td>");
In the address client has to submit his address,but if there space in the address value as (united state) then mycode is not working
Please Help
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,859
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 344
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: pass variable with space

  #4  
Jan 13th, 2008
You have been given your answer.

A URI can't contain any spaces and some other special characters, and if they do, they need to be encoded. With the way you are currently doing things, when the country name with spaces is encountered, the URI becomes report.jsp?address=some address when it should have been report.jsp?address=some%20address .

Using scriptlets in your JSP file is a bad practice not to mention that accessing a database from the JSP file is disastrous.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 7:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC