aspose file tools*
The moose likes Servlets and the fly likes Problem in getting # symbol from URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in getting # symbol from URL" Watch "Problem in getting # symbol from URL" New topic
Author

Problem in getting # symbol from URL

Jay Rpatel
Greenhorn

Joined: Nov 08, 2010
Posts: 4
For my project I am sending the HTML value from one text editor. For that I had set the character set to UTF-8. Here I am sending value through URL. In the text editor I am Providing the facility of changing the color of text.

Now when I change the color of text then on the servlet page where I had to get those values and to store it on database, am not able to get the entire value from URL. I am just getting the value before '#' symbol.

Ex.
I am sending following HTML value from URL.

<p>Add Your Text<font class="Apple-style-span" color="#FFCC33"> Here.</font></p>

and while getting this value on servlet I got URL:

localhost:23056/OUMS/recent_event?text=%3Cp%3EAdd%20Your%20Text%3Cfont%20class=%22Apple-style-span%22%20color=%22#FFCC33%22%3E%20Here.%3C/font%3E%3C/p%3E%20%20&col_id=c1

And when I display the value of 'text' variable then it shows:

<p>Add Your Text<font class="Apple-style-span" color="

Here it is noticeable that value of 'text' variable after '#' symbol is not visible on my servlet page.
What's the Solution of this??

Please Reply fast...

>
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A hash symbol has meaning in a URL (it links to a fragment identifier in a document). You will need to URL encode it.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

How are you URL-encoding your values such that the # is not being correctly encoded?

You aren't doing it with your own code, are you?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jay Rpatel
Greenhorn

Joined: Nov 08, 2010
Posts: 4
But can you help me how to encode the URL, and let me know you that before around 20 days this problem was not raised where I was using the same code. but after formatting my laptop and installing softwares again I start getting this problem
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18902
    
    8

Use one of the static methods from the java.net.URLEncoder class. Encode the parameter values. That's all you have to do in your code. Rebooting and reinstalling should have no effect if you do that.
Jay Rpatel
Greenhorn

Joined: Nov 08, 2010
Posts: 4
Thanks all for your valuable suggestions I had tried URLEncoding but still it was causing problem in safari browser where it was working perfectly with mozila.
So I find another way that now I am sending the value through hidden variable to servlet and now it is working perfectly.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in getting # symbol from URL