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

Recommended Answers

All 3 Replies

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.