Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Getting the value after #  RSS feed

 
Sheriff
Posts: 9613
37
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???
 
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: 9613
37
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 ?
 
Author and all-around good cowpoke
Rancher
Posts: 13078
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: 9613
37
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 ]
 
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: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your query string looks like:

www.aa.com/page?category=1#15



WHY did your original post give the example:

www.aaa.com/page.html#22



 
Ankit Garg
Sheriff
Posts: 9613
37
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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!