aspose file tools*
The moose likes Servlets and the fly likes Getting URL's from the server for use in the sevlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting URL Watch "Getting URL New topic
Author

Getting URL's from the server for use in the sevlet.

William Wild
Greenhorn

Joined: Dec 10, 2002
Posts: 23
Hi all,
How can you retreive the context URL (in the form http://xx ort/yy/) from within the servlet?
I need to be able to use it as the start of the xsl-t stylesheet url to embed in my xml data. Unfortunatly, all I have found are methods with in ServletContext, but they do not return the http:// section, only the paths from the context root or system paths.
Does anyone know of a method that I can use to get the full url path??
Kind regards
Simon


--<p>Bill<p>"Make it idiot proof,<br /> and someone will make a better idiot" -- ANON
William Wild
Greenhorn

Joined: Dec 10, 2002
Posts: 23
I will answer my own question here, incase anyone else has the same problem. With much calling of every method I could find I came up with this solution.
If the call from the client is in post form then this should work.

If anyone knows of an other solution that may be a bit more portable I would be greatful.
Cheers
Bill
preveeth ott
Greenhorn

Joined: Dec 10, 2002
Posts: 2
hi
try
HttpUtils.getRequestURL(request)
followed by some string manipulating, u should be able to get the result
chow chow
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting URL's from the server for use in the sevlet.