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


Java HttpServletResponse.getWriter方法代码示例

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


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

示例1: printError

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Displays some error output in the HTML response.
 */
private void printError(final String locale, HttpServletResponse resp,
        String errorText) throws IOException {
    resp.setCharacterEncoding("UTF-8");
    resp.setContentType("text/html; charset=UTF-8");

    String title = Messages.get(locale, "servlet_notification_title");
    String error = Messages.get(locale, "servlet_notification_error",
            new Object[] { errorText });

    String html = Messages.get(locale, "servlet_notification_html",
            new Object[] { title, title, error });
    PrintWriter out = resp.getWriter();

    out.println(html);
    out.close();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:NotificationServlet.java

示例2: execute

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/package-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:17,代码来源:PackageServletHandler.java

示例3: commence

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) throws IOException, ServletException {

	// Authentication failed, send error response.
	response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
	response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName() + "");

	PrintWriter writer = response.getWriter();
	writer.println("HTTP Status 401 : " + authException.getMessage());
}
 
开发者ID:edylle,项目名称:hockey-game,代码行数:11,代码来源:CustomBasicAuthenticationEntryPoint.java

示例4: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();

    String uname = request.getParameter("uname");
       String upwd = request.getParameter("upwd");

    if(uname.equals("root") && upwd.equals("root")) {
        out.println("Login Success"); 
        }else {
      out.println("Login Failure");
    }
}
 
开发者ID:pratikdimble,项目名称:Servlet_Applet_Communication,代码行数:13,代码来源:LoginServlet.java

示例5: preHandle

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object arg2) throws Exception {
	//1、获取请求的参数
	String requestUrl = request.getServletPath(); 
	String ticket = CookieUtil.getCookieValueByName(request,TitanConstant.TICKET_PREFIX);
	//2、验证url
	if((null != uncheckUrls) && (0 < uncheckUrls.size()) && (uncheckUrls.contains(requestUrl))){
		return true;
	}else{
		 //3、验证ticket
		String ticketInRedis = jedisCluster.get(TitanConstant.TICKET_PREFIX + ticket);
		if(StringUtils.isBlank(ticket) || StringUtils.isBlank(ticketInRedis)) {
			logger.warn("登录拦截,requestUrl:{},ticket:{},ticketInRedis:{}",requestUrl,ticket,ticketInRedis);
			PrintWriter out = response.getWriter();  
	        out.println("<html>");      
	        out.println("<script>");      
	        out.println("window.open ('"+request.getContextPath()+"/login.html','_top')");      
	        out.println("</script>");      
	        out.println("</html>"); 
		}else {
			return true;
		}
	}
	return false;
}
 
开发者ID:yunjiweidian,项目名称:TITAN,代码行数:26,代码来源:LoginInterceptor.java

示例6: aliPayNotifyRes

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 支付宝移动支付后台通知响应
 * @param request
 * @param response
 * @return
 * @throws ServletException
 * @throws IOException
    */
@RequestMapping(value = "/pay/aliPayNotifyRes.htm")
public void aliPayNotifyRes(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String result =  doAliPayRes(request, response);
	if(result != null) {
		_log.info("alipay notify response: {}", result);
		response.setContentType("text/html");
		PrintWriter pw;
		try {
			pw = response.getWriter();
			pw.print(result);

		} catch (IOException e) {
			_log.error("Pay response write exception.", e);
		}
	}

}
 
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:26,代码来源:Notify4AliPayController.java

示例7: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();

        // 获取值
        String orderId = request.getParameter("orderId");

        OrderInfo orderInfo = new OrderInfoServiceImpl().query(orderId);

        OrderToTable toTable = new OrderToTable(orderInfo.getOrderId(), orderInfo.getOrderName(), orderInfo.getOrderPhone()
                , orderInfo.getOrderIDcard(), orderInfo.getArrireDate(), orderInfo.getLeaveDate()
                , new RoomTypeServiceImpl().query(orderInfo.getTypeId().getTypeId()).getTypeId()
                , orderInfo.getCheckNum(), orderInfo.getPrice(), orderInfo.getCheckPrice()
                , orderInfo.getDiscount(), orderInfo.getDiscountReason(), orderInfo.getAddBed()
                , orderInfo.getAddBedPrice(), orderInfo.getOrderMoney(), orderInfo.getOrderState()
                , orderInfo.getRemark(), orderInfo.getOperatorId().getLoginName());

        Gson gson = new Gson();
        out.print(gson.toJson(toTable));
    }
 
开发者ID:inkss,项目名称:hotelbook-JavaWeb,代码行数:23,代码来源:QueryOrderInfoServlet.java

示例8: execute

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String method=retriveMethod(req);
	if(method!=null){
		invokeMethod(method, req, resp);
	}else{
		VelocityContext context = new VelocityContext();
		context.put("contextPath", req.getContextPath());
		String file=req.getParameter("file");
		String project = buildProjectNameFromFile(file);
		if(project!=null){
			context.put("project", project);
		}
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		Template template=ve.getTemplate("html/decisiontree-editor.html","utf-8");
		PrintWriter writer=resp.getWriter();
		template.merge(context, writer);
		writer.close();
	}
}
 
开发者ID:youseries,项目名称:urule,代码行数:22,代码来源:DecisionTreeEditorServletHandler.java

示例9: service

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    log.info("ip[" + req.getRemoteAddr() + "] requestURL[" + req.getRequestURL() + "] Query["
            + req.getQueryString() + "]");

    try {
        flow.execute(getServletContext(), req, resp);
    } catch (Exception e) {
        log.error("flow execution error", e);
        resp.setContentType("text/plane; charset=UTF-8");
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        PrintWriter pw = resp.getWriter();
        pw.println(e.getMessage());
        pw.close();
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:17,代码来源:DifferenceServlet.java

示例10: doHandleRequest

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
protected ModelAndView doHandleRequest(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	String lobId=request.getParameter("lobId");
	String xml=lobStoreService.getString(lobId);
	response.setContentType("text/plain; charset=UTF-8");
	response.setHeader("Pragma", "No-cache");
       response.setHeader("Cache-Control", "no-cache");
       response.setDateHeader("Expires", 0);
       PrintWriter writer=response.getWriter();
       xml=(xml==null)?"":xml;
       writer.write(xml);
       writer.flush();
       writer.close();
	return null;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:17,代码来源:LoadProcessController.java

示例11: generateMetadataForIdp

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Displays the identity provider metadata.
 * Checks to make sure metadata exists, and if not, generates it first.
 *
 * @param response servlet response
 * @throws IOException the iO exception
 */
@GetMapping(path = SamlIdPConstants.ENDPOINT_IDP_METADATA)
public void generateMetadataForIdp(final HttpServletResponse response) throws IOException {
    final File metadataFile = this.metadataAndCertificatesGenerationService.performGenerationSteps();
    final String contents = FileUtils.readFileToString(metadataFile, StandardCharsets.UTF_8);
    response.setContentType(CONTENT_TYPE);
    response.setStatus(HttpServletResponse.SC_OK);
    try (PrintWriter writer = response.getWriter()) {
        LOGGER.debug("Producing metadata for the response");
        writer.write(contents);
        writer.flush();
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:SamlMetadataController.java

示例12: handleRequest

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	StringBuilder result = new StringBuilder();
	ScheduleMachine m = scheduleMachineFactory.newInstance(String.valueOf(System.currentTimeMillis()), "dtstest");
	m.addContext("goto", 2);
	m.addContext("_i", 3);
	m.run();

	response.setContentType("text/html;charset=utf-8");
	PrintWriter out = response.getWriter();
	out.println(result);
	return null;
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:14,代码来源:DTSController.java

示例13: commence

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void commence ( HttpServletRequest request ,
					   HttpServletResponse response ,
					   AuthenticationException authException ) throws IOException {
	response.setHeader( "Content-type" , MediaType.APPLICATION_JSON_UTF8_VALUE );
	response.setCharacterEncoding( StandardCharsets.UTF_8.displayName() );
	try ( PrintWriter out = response.getWriter() ) {
		out.print( JsonUtils.toCustomizationJson( ResponseEntityPro.unauthorized( "未经授权:身份验证令牌丢失或无效。" ) ) );
	}
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:11,代码来源:JwtAuthenticationEntryPoint.java

示例14: attackHandle

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
@Override
public void attackHandle ( HttpServletRequest request , HttpServletResponse response , String parameters ) throws
                                                                                                           IOException {
    response.setHeader( "Content-type" , MediaType.APPLICATION_JSON_UTF8_VALUE );
    response.setCharacterEncoding( StandardCharsets.UTF_8.displayName() );
    try ( PrintWriter out = response.getWriter() ) {
        out.print( JsonUtils.toCustomizationJson( ResponseEntityPro.badRequest( "请求内容包含非法字符,原请求内容:\n" + parameters ) ) );
    }
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:10,代码来源:DefaultInjectionAttackHandler.java

示例15: saveManagedEntitiesOrdering

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private void saveManagedEntitiesOrdering(HttpServletRequest req, HttpServletResponse resp,
                                         EntitiesService as, ResourceBundle backendMessages,
                                         ResourceBundle messages) throws IOException {
  xLogger.fine("Entering saveManagedEntitiesOrdering");
  String userId = req.getParameter(USERID);
  if (userId == null || userId.isEmpty()) {
    xLogger.severe("Invalid, null or empty userId. {0}", userId);
    return;
  }
  String routeQueryString = req.getParameter("routequerystring");
  if (routeQueryString == null || routeQueryString.isEmpty()) {
    xLogger.severe("Invalid, null or empty routeQueryString. {0}", routeQueryString);
    return;
  }

  String message = null;
  xLogger.fine("userId = {0}", userId);
  xLogger.fine("routeQueryString = {0}", routeQueryString);
  // Get the domain Id
  SecureUserDetails sUser = SecurityMgr.getUserDetails(req.getSession());
  Long domainId = SessionMgr.getCurrentDomain(req.getSession(), sUser.getUsername());

  try {
    as.updateManagedEntitiesOrdering(domainId, userId, routeQueryString);
  } catch (ServiceException e) {
    xLogger.severe("Exception when saving managed entities route for userID {0}", userId);
    message = backendMessages.getString("error") + ": " + e.getMessage();
  }
  String jsonString = null;
  if (message != null && !message.isEmpty()) {
    // There was an error
    jsonString = "{ \"st\" : \"1\", \"msg\" : \"" + message + "\" } ";
    resp.setStatus(500);
  } else {
    // Success
    jsonString = "{ \"st\" : \"0\", \"msg\" : \"\" }";
    resp.setStatus(200);
  }
  resp.setContentType(JsonRestServlet.JSON_UTF8);
  PrintWriter pw = resp.getWriter();
  pw.write(jsonString);
  pw.close();
  xLogger.fine("Exiting saveManagedEntitiesOrdering");
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:45,代码来源:CreateEntityServlet.java


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