• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting the value after #

 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the HttpServletRequest method you want is getPathInfo()

Bill
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic