Getting server information

(Difference between revisions)
Jump to: navigation, search
(initial content)
 
Line 6: Line 6:
 
  CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
 
  CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
 
  out.print(cms.getRequestContext().getRemoteAddress());
 
  out.print(cms.getRequestContext().getRemoteAddress());
 +
 +
==Get the hostname==
 +
This one is pretty typical of any JSP.
 +
 +
String hostname = request.getServerName();
 +
 +
==Get the URI==
 +
There may be other ways, but this is what I got to work.
 +
CmsJspActionElement element = new CmsJspActionElement(pageContext, request, response);
 +
CmsObject obj = element.getCmsObject();
 +
String uri = obj.getRequestContext().getUri();

Revision as of 00:48, 28 June 2007

You can get a variety of information about your server from OpenCms, however sometimes it is a more round-about route.

Get the Server IP address

To get the IP of the client use the following code. If you use the request object, you most likely will get the proxy IP.

CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
out.print(cms.getRequestContext().getRemoteAddress());

Get the hostname

This one is pretty typical of any JSP.

String hostname = request.getServerName();

Get the URI

There may be other ways, but this is what I got to work.

CmsJspActionElement element = new CmsJspActionElement(pageContext, request, response);
CmsObject obj = element.getCmsObject();
String uri = obj.getRequestContext().getUri();
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox