aspose file tools*
The moose likes JSP and the fly likes UrlEncode the String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "UrlEncode the String" Watch "UrlEncode the String" New topic
Author

UrlEncode the String

Raihan Jamal
Ranch Hand

Joined: Mar 23, 2010
Posts: 86
I am trying to url encode the string..



I tried this way

But I got the error as

The function urlEncode must be used with a prefix when a default namespace is not specified
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

urlEncode() is at static method on URLEncoder. This means you need to call URLEncoder.urlEncode(filter.value.display) instead.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What is filter? What makes you think that it even has a urlEncode() method?

Why are you URL-encoding it in the first place? If its for use on a URL, why not just use <c:url>?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Raihan Jamal
Ranch Hand

Joined: Mar 23, 2010
Posts: 86
Thanks for replying back, I did the changes as said by you:-



But still I am getting the same error as



Any suggestions??
Raihan Jamal
Ranch Hand

Joined: Mar 23, 2010
Posts: 86
@Bear Bibeault, In my app there are some string that has special characters like + and I am sending the query back to solr... So that spcecial character is causing problem.. So that's why I have to encode that string so that solr accept that query parameter...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

Well, yeah, you can't just call any old static method inside an EL expression. That isn't what they are for.
Raihan Jamal
Ranch Hand

Joined: Mar 23, 2010
Posts: 86
@Paul, In my app there are some string that has special characters like + and I am sending this query back to solr... So that spcecial character is causing problem.. So that's why I have to encode that string so that solr accept that query parameter that has special character.... That's why I want to url encode that expression..
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

Raihan Jamal wrote:In my app there are some string that has special characters like + and I am sending the query back to solr... So that spcecial character is causing problem.. So that's why I have to encode that string so that solr accept that query parameter...


Normally a browser will automatically URL-encode parameters sent from a <form> element. If that isn't happening then that means you aren't "sending the query back to solr" from a <form> element from the browser. Which means that "sending back to solr" is being done in some other way from the browser. Would you like to fill us in on the details? All of the details would be nice, so we don't have to have this sort of back-and-forth again.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

TellTheDetails -- making us guess isn't going to help us help you.
Raihan Jamal
Ranch Hand

Joined: Mar 23, 2010
Posts: 86
@Paul.. I am not sending any data from the form element back to Solr... In my solr all the data is there... and I have created an app in which data is coming from the solr... So some data has + sign like
Mac+
and they are hyperlinked... If we click on this hyperlink then all the data related to that particular data will show up in my browser... So in this case if I click on any data that has + sign then I am not getting any result back... But If I try to query the solr from its admin using Mac%2B then I am getting the result back...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

What hyperlink is that?

(Remember how I asked for a full description of the problem?)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UrlEncode the String
 
Similar Threads
Not able to use EL in JSTL
JSTL c:out not working but other commands working
method showing different returns when declared on JSP or Servlet
pulling my hair out
Possible work around for displaying blanks as default values for text fields tied to float-JSTL