Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I obtain server variables using apache wicket 1.54?

I am trying to get the name and ip of the current server in which my web application is running on. I am not sure how to do this is wicket 1.54. I need to know how to get at my server variables.

In wicket 1.4 you could do:

HttpServletRequest hsr = getWebRequestCycle().getWebRequest().getHttpServletRequest();

Then you could use hsr to grab headers or attributes.

Edit:

In wicket 1.54 the equivalent line is:

HttpServletRequest hsr = (HttpServletRequest)getRequestCycle().getRequest().getContainerRequest();
hsr.getAttribute("SERVER_NAME");

However I always am getting a null string.

like image 817
Jared Sol Avatar asked Dec 06 '25 08:12

Jared Sol


1 Answers

This works for me with Wicket 1.5.5 inside a WebPage:

HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
String serverName = request.getServerName();
String remoteAddr = request.getRemoteAddr();
like image 182
jordeu Avatar answered Dec 07 '25 21:12

jordeu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!