Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting the value after #

 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet which recieves a request with a URL something like this

www.aaa.com/page.html#22

Now I want to take out the value 22 in my servlet. Is there any way to do that???
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use String#split(regex) , where regex as "#" OR you can get String#substring(index) , where index as , index of "#" in string !

Hope this helps !
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No the problem is not that. Is there any way to get the full request string. I have tried request.getQueryString, request.getRequestURL, request.getRequestURI, but none of them gives me the whole request string which includes #22...
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ankit Garg:
I have a servlet which recieves a request with a URL something like this

www.aaa.com/page.html#22



How is your request going to server ? Whats in your action URI ? and What your are getting at Servlet using request.getRequestURL, request.getRequestURI methods ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the HttpServletRequest method you want is getPathInfo()

Bill
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getPathInfo returns the URL from the servlet mapping to the query string...

Actually my servlet also receives some query string. and the # is appended to the URL after the query string like this-

www.aa.com/page?category=1#15
[ September 30, 2008: Message edited by: Ankit Garg ]
 
Victor Dolirio
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the '#' character is actually used by the browsers to anchor the page, i�ve had experienced this and nothing beyond the # is submited to server so if really want get that character you must use the escape characters for URL, take a google on that .
[ September 30, 2008: Message edited by: Victor Dolirio ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your query string looks like:


WHY did your original post give the example:


 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
If your query string looks like:




I didn't knew that it would make a difference...Sorry for that...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic