本文整理汇总了Java中javax.servlet.http.HttpServletRequest.getLocalPort方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletRequest.getLocalPort方法的具体用法?Java HttpServletRequest.getLocalPort怎么用?Java HttpServletRequest.getLocalPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.http.HttpServletRequest
的用法示例。
在下文中一共展示了HttpServletRequest.getLocalPort方法的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: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
示例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-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();
}
}
示例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/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();
}
}
示例8: 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();
}
}
示例9: XForwardedRequest
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public XForwardedRequest(HttpServletRequest request) {
super(request);
this.localPort = request.getLocalPort();
this.remoteAddr = request.getRemoteAddr();
this.remoteHost = request.getRemoteHost();
this.scheme = request.getScheme();
this.secure = request.isSecure();
this.serverPort = request.getServerPort();
headers = new HashMap<String, List<String>>();
for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements();) {
String header = headerNames.nextElement();
headers.put(header, Collections.list(request.getHeaders(header)));
}
}
示例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: XForwardedRequest
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public XForwardedRequest(HttpServletRequest request) {
super(request);
this.localPort = request.getLocalPort();
this.remoteAddr = request.getRemoteAddr();
this.remoteHost = request.getRemoteHost();
this.scheme = request.getScheme();
this.secure = request.isSecure();
this.serverPort = request.getServerPort();
headers = new HashMap<String, List<String>>();
for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements();) {
String header = headerNames.nextElement();
headers.put(header, Collections.list(request.getHeaders(header)));
}
}
示例14: scheduleChildProcessMonitoring
import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@POST
@Path( "scheduleChildProcessMonitoring")
@Consumes( MediaType.APPLICATION_JSON)
@Produces( MediaType.APPLICATION_JSON)
public Response scheduleChildProcessMonitoring(
@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.scheduleChildProcessMonitoring(agent,
monitoringPojo.getParentProcess(),
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 child process monitoring with parameters '"
+ monitoringPojo.toString() + "'\"}";
return Response.ok(statusMessage).build();
}
示例15: 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();
}