Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > # and other special characters in querystring - JSP

Reply
Thread Tools

# and other special characters in querystring - JSP

 
 
Hemaraj
Guest
Posts: n/a
 
      08-22-2007
Dear Java group

I have a JSP page which has some hyperlinks that contain values such as

http://www.mydomain.com#Something1
http://www.mydomain.com#Something2

When I click on them, they should be passed as value of query string to a
servlet. When the servlet is run, I can see in url field of the browser that
the correct value was passed ; for example I see:


http://localhost:8080/MyWebSite/Show...com#Something2



Where ShowDetails is the name of the servlet that is getting this selected
item through

String Selected1 = request.getParameter("SelectedItem");



However, when I want to display this field using

out.println("<p>Value " + Selected1 + "</p>");



I only see http://www.mydomain.com - what I want to see is :
http://www.mydomain.com#Something2 - meaning, the part #something1 is not
there anymore.

How to solve this problem?

Thank you


 
Reply With Quote
 
 
 
 
Jan =?UTF-8?B?VGhvbcOk?=
Guest
Posts: n/a
 
      08-22-2007
Hi Hemaraj,

the #-part is interpreted by the browser and not sent to the server. It
might appear in the URL line, however only the part before the # will be
passed to the server. You will have to URL-encode the string that you put
into the link if you want to send that information to the server. However
then the browser will not jump to the anchors anymore. To achieve both one
could hack:

http://www.mydomain.com%23Something1#Something1

You would have to create some magic servlet mapping to make that work. I
wonder, though why you would want to send the anchor part to the server in
that URL instead of adding it to a parameter:

http://www.mydomain.com?anchor=Something1#Something1

Hope that helps.

Best regards,
Jan


Hemaraj wrote:

> I have a JSP page which has some hyperlinks that contain values such as
>
> http://www.mydomain.com#Something1
>
> When I click on them, they should be passed as value of query string to a
> servlet.
> I only see http://www.mydomain.com - what I want to see is :
> http://www.mydomain.com#Something2 - meaning, the part #something1 is not
> there anymore.


--
__________________________________________________ _______________________
insOMnia - We never sleep...
http://www.insOMnia-hq.de
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting utf-8 characters -special characters majna Javascript 4 09-19-2007 01:53 PM
Remove only special characters and junk characters from a file rvino Perl 0 08-14-2007 07:23 AM
Re: Meta-Characters, Special Characters xah@xahlee.org Java 2 05-31-2007 09:25 AM
How to convert HTML special characters to the real characters with a Java script Stefan Mueller HTML 3 07-23-2006 10:09 PM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM



Advertisments