当前位置: 首页>>代码示例>>Java>>正文


Java Request.getParameter方法代码示例

本文整理汇总了Java中org.glassfish.grizzly.http.server.Request.getParameter方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getParameter方法的具体用法?Java Request.getParameter怎么用?Java Request.getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.grizzly.http.server.Request的用法示例。


在下文中一共展示了Request.getParameter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
    public void service(Request request, Response response) throws Exception {

        logger.debug("Starting service");
        super.service(request, response);

        String naf = request.getParameter("naf");
        KAFDocument doc;

        try {
            doc = pipeline.parseFromString(naf);
        } catch (Exception e) {
            e.printStackTrace();
            throw new Exception(e);
        }

//        File temp = File.createTempFile("temp-file-name", ".tmp");
//        logger.info("Created temp file " + temp.getAbsolutePath());
//        doc.save(temp);

        logger.trace(doc.toString());

        writeOutput(response, "text/xml", doc.toString());
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:25,代码来源:NafHandler.java

示例2: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {

	super.service(request, response);

	String naf = request.getParameter("naf");
	KAFDocument document = KAFDocument.createFromStream(new StringReader(naf));

	NAFFilter filter = NAFFilter.builder().withSRLRoleLinking(false, false).withOpinionLinking(false, false).build();
	RDFGenerator generator = RDFGenerator.DEFAULT;
	Renderer renderer = Renderer.DEFAULT;

	filter.filter(document);
	final Model model = generator.generate(document, null);
	StringWriter writer = new StringWriter();
	renderer.renderAll(writer, document, model, null, null);
	String res = writer.toString();

	super.writeOutput(response, "text/html", res);
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:21,代码来源:NafVisualizeHandler.java

示例3: handle

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
protected boolean handle(String uri, Request request, Response response)
        throws Exception {
    String mediaId = request.getParameter(PARAM_ID);
    Media media = catalogue.getMedia(mediaId);
    if (media != null && media.getFile() != null) {
        logger.trace("Serving up media {}", media);
        pickupContentType(response, media.getFile().getPath());
        sendFile(response, media.getFile());
        logger.trace("Served up media {}", media);
        return true;
    } else {
        logger.trace("Couldn't find media as referenced in request {}", uri);
        return false;
    }
}
 
开发者ID:KolonelKustard,项目名称:discodj,代码行数:17,代码来源:DiscoDjMediaHttpHandler.java

示例4: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {
	try {
		int port = request.getRemotePort();
		String address = request.getRemoteAddr();
		String holdConn = request.getParameter("hold");

		if ("false".equals(holdConn)) {
			logger.info("recv short request:[{}:{}]", address, port);
			String messageJson = request.getParameter("data");
			IMessage msg = context.getCodec().decode(messageJson);
			context.getMessageCenter().send(msg);
		} else {
			logger.info("recv long-poll request:[{}:{}]", address, port);
			PushError erro = context.beAddSub(request.getParameterMap());
			if (erro != null) {
				writeInfo(response, erro);
				return;
			}
			long timeout = context.getConfig().getConnTimeout();
			IRemoteSubcriber sub = new PollSubcriber(response, context);
			response.suspend(timeout, TimeUnit.MILLISECONDS, handler, this);
			context.getMessageCenter().addSubscriber(sub);
			request.setAttribute("sub", sub);
			
			logger.info("create long-poll client:[{}:{}]", address, port);
		}
	} catch (Exception e) {
		logger.error("occur error when process request", e);
	}
}
 
开发者ID:coderczp,项目名称:HtmlSocket,代码行数:32,代码来源:LongPollServer.java

示例5: writeInfo

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
private void writeInfo(Response response, Object info) {
	try {
		Writer writer = response.getWriter();
		Request request = response.getRequest();
		String jsonp = request.getParameter("callback");
		if (jsonp != null) {
			writer.write(String.format("%s('%s')", jsonp, info));
		} else {
			writer.write(info.toString());
		}
		writer.flush();
	} catch (IOException e) {
		logger.error("occur error when response", e);
	}
}
 
开发者ID:coderczp,项目名称:HtmlSocket,代码行数:16,代码来源:LongPollServer.java

示例6: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {
	String message = request.getParameter("data");
	logger.info("CreateTrackerAction : " + message);
	try {
		CreatePojo pojo = new Gson().fromJson(message, CreatePojo.class);
		Room room = null;
		long timeLimit = pojo.timeLimit;
		if (timeLimit < 0) {
			sendErrorResponse(response);
			return;
		}
		if (!YelliData.getYelliData().containsRoom(pojo.deviceId)) {
			room = YelliData.getYelliData().createRoom(pojo.deviceId);
		} else {
			room = YelliData.getYelliData().getRoomFromDeviceId(pojo.deviceId);
		}
		logger.info("Tracker Created : " + room.getTrackId());
		// remove room after however long the user specifies
		RemoveRoomTask removeRoomTask = new RemoveRoomTask(pojo.deviceId);
		Timer timer = new Timer();
		timer.schedule(removeRoomTask, timeLimit);
		sendResponse(room.getTrackId(), response);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:callmesusheel,项目名称:yelli,代码行数:29,代码来源:CreateTrackerApi.java

示例7: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {
	String message = request.getParameter("data");
	OnAction onAction = new UpdateTrackerAction();
	onAction.onMessage(message, null);
	response.getWriter().append("OK");
}
 
开发者ID:callmesusheel,项目名称:yelli,代码行数:8,代码来源:UpdateLocationApi.java

示例8: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {

	super.service(request, response);

	String text = request.getParameter("text");
	KAFDocument doc = text2naf(text, meta);
	doc = pipeline.parseFromNAF(doc);

	writeOutput(response, "text/xml", doc.toString());
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:12,代码来源:Text2NafHandler.java

示例9: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {

    request.setCharacterEncoding("UTF-8");

    Buffer postBody = request.getPostBody(1024);
    String text = postBody.toStringContent();

    if (request.getParameter("text") != null) {
        text = request.getParameter("text");
    }

    String outputFormat = request.getParameter("format");

    InputStream inputStream = new ByteArrayInputStream(text.getBytes());
    OutputStream outputStream = new ByteArrayOutputStream();

    TintRunner.OutputFormat format = TintRunner.getOutputFormat(outputFormat, TintRunner.OutputFormat.JSON);
    pipeline.run(inputStream, outputStream, format);

    LOGGER.debug("Text: {}", text);

    String output = outputStream.toString();

    writeOutput(response, contentTypes.get(format), output);
}
 
开发者ID:dhfbk,项目名称:tint,代码行数:27,代码来源:TintHandler.java

示例10: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
	public void service(Request request, Response response) throws Exception {

		super.service(request, response);

		String host = request.getHeader("x-forwarded-for");

		String referer = request.getHeader("referer");
		String okReferer = pipeline.getDefaultConfig().getProperty("back_referer");

		boolean backLink = false;
		if (okReferer != null || referer != null) {
			backLink = true;
		}

//		if (referer != null && okReferer != null && referer.equals(okReferer)) {
//			backLink = true;
//		}

		String text = request.getParameter("text");

		// Log for stats
		LOGGER.info("[SENTENCE]");
		LOGGER.info("Host: {}", host);
		LOGGER.info("Text: {}", text);

		KAFDocument doc = text2naf(text, meta);

		doc = pipeline.parseFromString(doc.toString());

		String viewString;
		viewString = doc.toString();
		try {

			HashMap<String, Object> demoProperties = new HashMap<>();
			demoProperties.put("renderer.template.title", "PIKES demo");
			if (backLink) {
				demoProperties.put("renderer.template.backlink", "javascript:history.back();");
			}
			else {
				demoProperties.put("renderer.template.backlink", pipeline.getDefaultConfig().getProperty("back_alt_link"));
				demoProperties.put("renderer.template.backlabel", pipeline.getDefaultConfig().getProperty("back_alt_text"));
			}

			boolean fusion = request.getParameter("rdf_fusion") != null;
			boolean normalization = request.getParameter("rdf_compaction") != null;

			demoProperties.put("generator.fusion", fusion);
			demoProperties.put("generator.normalization", normalization);

			NAFFilter filter = NAFFilter.builder().withProperties(pipeline.getDefaultConfig(), "filter").build();
			RDFGenerator generator = RDFGenerator.builder().withProperties(demoProperties, "generator").build();
			Renderer renderer = Renderer.builder().withProperties(demoProperties, "renderer").build();

			filter.filter(doc);
			final Model model = generator.generate(doc, null);
			StringWriter writer = new StringWriter();
			renderer.renderAll(writer, doc, model, null, null);
			viewString = writer.toString();

		} catch (Exception e) {
			e.printStackTrace();
			viewString = "Unable to show graph. <br /><br />\n<pre>" + doc.toString().replace("<", "&lt;").replace(">", "&gt;") + "</pre>";
		}

		super.writeOutput(response, "text/html", viewString);
	}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:68,代码来源:EverythingHandler.java

示例11: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
	public void service(Request request, Response response) throws Exception {

		super.service(request, response);

		String host = request.getHeader("x-forwarded-for");

		String referer = request.getHeader("referer");
		String okReferer = pipeline.getDefaultConfig().getProperty("back_referer");

		boolean backLink = false;
		if (referer != null && okReferer != null && referer.equals(okReferer)) {
			backLink = true;
		}

		String text = request.getParameter("text");

		// Log for stats
		LOGGER.info("[SENTENCE]");
		LOGGER.info("Host: {}", host);
		LOGGER.info("Text: {}", text);

		KAFDocument doc = text2naf(text, meta);

		doc = pipeline.parseFromString(doc.toString());

		String viewString;
		try {

			HashMap<String, Object> demoProperties = new HashMap<>();
			demoProperties.put("renderer.template.title", "PIKES demo");
			if (backLink) {
				demoProperties.put("renderer.template.backlink", "javascript:history.back();");
			}
			else {
				demoProperties.put("renderer.template.backlink", pipeline.getDefaultConfig().getProperty("back_alt_link"));
				demoProperties.put("renderer.template.backlabel", pipeline.getDefaultConfig().getProperty("back_alt_text"));
			}

			boolean fusion = request.getParameter("rdf_fusion") != null;
			boolean normalization = request.getParameter("rdf_compaction") != null;

			demoProperties.put("generator.fusion", fusion);
			demoProperties.put("generator.normalization", normalization);

			NAFFilter filter = NAFFilter.builder().withProperties(pipeline.getDefaultConfig(), "filter").build();
			RDFGenerator generator = RDFGenerator.builder().withProperties(demoProperties, "generator").build();
//			Renderer renderer = Renderer.builder().withProperties(demoProperties, "renderer").build();

			StringWriter writer = new StringWriter();
			RDFWriter rdfWriter = Rio.createWriter(RDFFormat.TRIG, writer);
			filter.filter(doc);
			List<Statement> statementList = new ArrayList<>();

			generator.generate(doc, null, statementList);
			RDFSource rdfSource = RDFSources.wrap(statementList);
			RDFProcessors.prefix(null).wrap(rdfSource).emit(rdfWriter, 1);

//			final Model model = generator.generate(doc, null);
//			StringWriter writer = new StringWriter();
//			renderer.renderAll(writer, doc, model, null, null);
			viewString = writer.toString();

		} catch (Exception e) {
			e.printStackTrace();
			viewString = "Unable to show graph. <br /><br />\n<pre>" + doc.toString().replace("<", "&lt;").replace(">", "&gt;") + "</pre>";
		}

		super.writeOutput(response, "text/plain", viewString);
	}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:71,代码来源:TriplesHandler.java

示例12: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {
    response.setHeader("Cache-Control", "no-cache, no-store");
   	try {
   		final GatfExecutorConfig gatfConfig = GatfConfigToolMojo.getGatfExecutorConfig(mojo, null);
		String basepath = gatfConfig.getOutFilesBasePath()==null?mojo.rootDir:gatfConfig.getOutFilesBasePath();
		String dirPath = basepath + SystemUtils.FILE_SEPARATOR + gatfConfig.getOutFilesDir();
		if(!new File(dirPath).exists()) {
			new File(dirPath).mkdir();
		}
		if(request.getMethod().equals(Method.GET) ) {
		    new CacheLessStaticHttpHandler(dirPath).service(request, response);
		} else if(request.getMethod().equals(Method.PUT) ) {
		    String action = request.getParameter("action");
		    String testcaseFileName = request.getParameter("testcaseFileName");
		    String testCaseName = request.getParameter("testCaseName");
		    boolean isServerLogsApi = request.getParameter("isServerLogsApi")!=null;
		    boolean isExternalLogsApi = request.getParameter("isExternalLogsApi")!=null;
		    TestCaseReport tcReport = null;
		    if(action.equals("replayTest"))
		    { 
		        tcReport = new org.codehaus.jackson.map.ObjectMapper().readValue(request.getInputStream(), 
		                TestCaseReport.class);
		        if(tcReport == null) {
		            throw new RuntimeException("Invalid testcase report details provided");
		        }
		    } 
		    else if(isExternalLogsApi && !action.equals("playTest"))
		    {
		        tcReport = new org.codehaus.jackson.map.ObjectMapper().readValue(request.getInputStream(), 
		                TestCaseReport.class);
		    }
		    Object[] out = executeTest(gatfConfig, tcReport, action, testcaseFileName, testCaseName, isServerLogsApi, isExternalLogsApi, 0, false);
		    if(out[1]!=null) {
		        response.setContentType(out[2].toString());
		        response.setContentLength(((String)out[1]).length());
		        response.getWriter().write((String)out[1]);
		    }
		    response.setStatus((HttpStatus)out[0]);
		}
   	} catch (Exception e) {
   		GatfConfigToolMojo.handleError(e, response, null);
	} finally {
	    if(lock.isLocked()) {
	        lock.unlock();
	    }
	}
   }
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:49,代码来源:GatfReportsHandler.java

示例13: service

import org.glassfish.grizzly.http.server.Request; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) throws Exception {

	super.service(request, response);

	String text = request.getParameter("text");
	KAFDocument doc = text2naf(text, meta);

	writeOutput(response, "text/xml", doc.toString());
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:11,代码来源:NafGenerateHandler.java


注:本文中的org.glassfish.grizzly.http.server.Request.getParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。