I have one query string in my JSP:
href='www.me-me.com/index.jsp?application=<%=
myBean.getApplication().replace("&","\\")
%>&appId=<%=
myBean.getAppId()
%>'>LINK
Now I am picking up the appID using request object in the index.jsp and using that appId I am pulling up the data from my DB to fill the page.
But I am getting a blank screen when myBean.getApplication is returning something like Application ##1, certainly because query is getting banged after encountering the "#".
I could replace "#" using the replace() method, but I do not find it reliable and good, as I am pulling that application name using the request object again in my index.jsp page, and the replacement of hashes would make it ugly. So is there a way where I can retain the "#"?
Any other out-of-the-box solution would be appreciated.
URL-encoding the values would be the right thing to do.
You can transport any string value as an URL parameter, but you must properly encode it or your URLs will break, just like you are experiencing it.
You’d need a
statement in your page, because that’s where
URLEncoderis defined.