• 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

How can I get servlet url

 
Ranch Hand
Posts: 35
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to use request.getRequestURL().toString() to get the current page URL. instead of getting url appears in the browse (http://localhost:8080/test/abc.do) I am getting (http://localhost:8080/test/showAbc.jsp).

I am partly know why this happened, because I set to dispatcher to showAbc.jsp in the servlet class. but can anyone tell me how to get the first url that appears in the browser?

thanks in advance
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method getRequestURL() would return the URL of the request submitted by the client. As I understand, the method would return the URL used for submitting the request.

I am getting (http://localhost:8080/test/showAbc.jsp)



Did you submit the request to showAbc.jsp?

If you want to know the URL of the page from which the request was sent, you can try reading the HTTP-REFERER header. By the way, are you trying to implement some security feature using this information? If not, why do you need this info for?

Cheers
Arvind
 
reply
    Bookmark Topic Watch Topic
  • New Topic