This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to get the full path upto application name

 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

This is Venkat. I have a requirement. I need to get the full path upto application name.

If the request browser URL is as shown below

http://localhost:8080/TestApplication/test.do


i need to get the path as http://localhost:8080/TestApplication/test.do


I have tried using

request.getRequestURL(), but it is returning the servlet mapping name also ( test.do). I need to get upto the application(context) name.


Please help me ASAP.



Thanks,
Venkat
 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry friends, here is the right request.




Hi ranchers,

This is Venkat. I have a requirement. I need to get the full path upto application name.

If the request browser URL is as shown below

http://localhost:8080/TestApplication/test.do


i need to get the path as http://localhost:8080/TestApplication


I have tried using

request.getRequestURL(), but it is returning the servlet mapping name also ( test.do). I need to get upto the application(context) name.


Please help me ASAP.



Thanks,
Venkat
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkata Guru,

A couple tips for posting to JavaRanch.

1) You can always go back and edit your posts by clicking on the icon in that post.
Posting several times in the same thread lowers your chance of getting an answer because some people will see that the question already has responses and assume that the question has already been answered.

2) Don't use "Urgent" or "ASAP" in your posts.
Many people will ignore posts if they see this in them.
See: http://faq.javaranch.com/java/EaseUp to find out why.

We have more tips for posting to JavaRanch here:
http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer your question, look at the API for
HttpServletRequest

It has methods for finding each part of the full URL, including domain, port, scheme, etc...
You should be able to build anything you need using it.
 
Kathiresan Chinnasamy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Help me anyone know the answer for this
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question has already been answered by Ben.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!