本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getLocalAddr方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getLocalAddr方法的具體用法?Java HttpServletRequest.getLocalAddr怎麽用?Java HttpServletRequest.getLocalAddr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.http.HttpServletRequest
的用法示例。
在下文中一共展示了HttpServletRequest.getLocalAddr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort()
+ req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/season-internet-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: APIRequest
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public APIRequest(HttpServletRequest request) {
this.request = request;
header = new HashMap<String, Object>();
Enumeration e = request.getHeaderNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
Object value = request.getHeader(name);
header.put(name, value);
}
params = getParamesMap(request.getParameterMap());
url = request.getRequestURL().toString();
uri = request.getRequestURI();
remoteAddr = request.getRemoteAddr();
remoteHost = request.getRemoteHost();
remotePort = request.getRemotePort();
contextPath = request.getContextPath();
localAddr = request.getLocalAddr();
characterEncoding = request.getCharacterEncoding();
localName = request.getLocalName();
localPort = request.getLocalPort();
method = request.getMethod();
queryString = request.getQueryString();
}
示例3: stopMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "stopMonitoring")
@Produces( MediaType.APPLICATION_JSON)
public Response stopMonitoring(
@Context HttpServletRequest request,
BasePojo basePojo ) {
final String caller = getCaller(request, basePojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, basePojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
restSystemMonitor.stopMonitoring(agent);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
return Response.ok("{\"status\":\"monitoring stopped.\"}").build();
}
示例4: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort() + req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/ramus-rmi-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort() + req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/ramus-http-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort() + req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/ramus-internet-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort()
+ req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/season-tcp-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例8: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String path = "http://" + req.getLocalAddr() + ":" + req.getLocalPort() + req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/ramus-local.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例9: accept
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void accept(HttpServletRequest req, HttpServletResponse resp) {
try {
String localAddr = req.getLocalAddr();
Properties properties = EngineFactory.getPropeties();
if (properties.getProperty("hostname") != null) {
localAddr = properties.getProperty("hostname");
}
String path = "http://" + localAddr + ":" + req.getLocalPort() + req.getContextPath();
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/jnlp/ramus-client.jnlp");
ByteArrayOutputStream out = new ByteArrayOutputStream();
int r;
while ((r = is.read()) >= 0)
out.write(r);
String string = MessageFormat.format(new String(out.toByteArray(),
"UTF8"), path);
resp.setContentType("application/x-java-jnlp-file");
OutputStream o = resp.getOutputStream();
o.write(string.getBytes("UTF8"));
o.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例10: initializeMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
* Initialize Monitoring context Must be called before calling any
* scheduleXYZMonitoring REST method
*/
@POST
@Path( "initializeMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response initializeMonitoring(
@Context HttpServletRequest request,
BasePojo basePojo ) {
final String caller = getCaller(request, basePojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, basePojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
restSystemMonitor.initializeMonitoringContext(agent);
return Response.ok("{\"status\":\"monitoring context initialized.\"}").build();
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
}
示例11: scheduleSystemMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "scheduleSystemMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleSystemMonitoring(
@Context HttpServletRequest request,
ScheduleSystemMonitoringPojo monitoringPojo ) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleSystemMonitoring(agent,
monitoringPojo.getReadings());
restSystemMonitor.setScheduledReadingTypes(readings);
return Response.ok("{\"status\":\"scheduled system monitoring for readings '"
+ Arrays.toString(monitoringPojo.getReadings()) + "'\"}")
.build();
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
}
示例12: scheduleMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "scheduleMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleMonitoring(
@Context HttpServletRequest request,
ScheduleMonitoringPojo monitoringPojo ) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleMonitoring(agent,
monitoringPojo.getReading(),
monitoringPojo.getReadingParametersAsMap());
restSystemMonitor.setScheduledReadingTypes(readings);
String readingParametersAsString = entrySetAsString(monitoringPojo.getReadingParametersAsMap());
return Response.ok("{\"status\":\"scheduled monitoring for reading '"
+ monitoringPojo.getReading() + "' and readingParameters '"
+ readingParametersAsString + "'\"}")
.build();
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
}
示例13: scheduleProcessMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "scheduleProcessMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleProcessMonitoring(
@Context HttpServletRequest request,
ScheduleProcessMonitoringPojo monitoringPojo ) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleProcessMonitoring(agent,
monitoringPojo.getProcessPattern(),
monitoringPojo.getProcessAlias(),
monitoringPojo.getProcessUsername(),
monitoringPojo.getProcessReadingTypes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled process monitoring with parameters '"
+ monitoringPojo.toString() + "'\"}";
return Response.ok(statusMessage).build();
}
示例14: scheduleJvmMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "scheduleJvmMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleJvmMonitoring(
@Context HttpServletRequest request,
ScheduleJvmMonitoringPojo monitoringPojo ) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleJvmMonitoring(agent,
monitoringPojo.getJvmPort(),
(monitoringPojo.getAlias() == null)
? ""
: monitoringPojo.getAlias(),
monitoringPojo.getJvmReadingTypes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled JVM monitoring with parameters '"
+ monitoringPojo.toString() + "'\"}";
return Response.ok(statusMessage).build();
}
示例15: scheduleCustomJvmMonitoring
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@POST
@Path( "scheduleCustomJvmMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleCustomJvmMonitoring(
@Context HttpServletRequest request,
ScheduleCustomJvmMonitoringPojo monitoringPojo ) {
final String caller = getCaller(request, monitoringPojo, false);
ThreadsPerCaller.registerThread(caller);
try {
SessionData sd = getSessionData(request, monitoringPojo);
RestSystemMonitor restSystemMonitor = sd.getSystemMonitor();
String agent = request.getLocalAddr() + ":" + request.getLocalPort();
Set<ReadingBean> readings = restSystemMonitor.scheduleCustomJvmMonitoring(agent,
monitoringPojo.getJmxPort(),
monitoringPojo.getAlias(),
monitoringPojo.getMbeanName(),
monitoringPojo.getUnit(),
monitoringPojo.getMbeanAttributes());
restSystemMonitor.setScheduledReadingTypes(readings);
} catch (Exception e) {
return Response.serverError().entity(new ErrorPojo(e)).build();
} finally {
ThreadsPerCaller.unregisterThread();
}
String statusMessage = "{\"status \": \"scheduled custom JVM monitoring with parameters '"
+ monitoringPojo.toString() + "'\"}";
return Response.ok(statusMessage).build();
}