[opencms-dev] Server name

Martin Kuba makub at ics.muni.cz
Fri Nov 12 17:34:35 CET 2004


Moro Álvarez wrote:
> Hello, I´ve OpenCMS in http://pcserver/ocms/opencms/ 
> <http://loclahost/ocms/opencms/>.....
>  
> In a jsp How I cant get the server url ("http://pcserver/ocms")?

Not directly. You can do:

request.getRequestURL()

which will give you the full URL.

Or you can try to construct it from pieces:

request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()

For details see
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html

Martin
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Supercomputing Center Brno             Martin Kuba
Institute of Computer Science    email: makub at ics.muni.cz
Masaryk University             http://www.ics.muni.cz/~makub/
Botanicka 68a, 60200 Brno, CZ     mobil: +420-603-533775
--------------------------------------------------------------



More information about the opencms-dev mailing list