Java Code Examples for javax.servlet.http.HttpServletResponse#setDateHeader()

The following examples show how to use javax.servlet.http.HttpServletResponse#setDateHeader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseAdminApplication.java    From base-admin with MIT License 6 votes vote down vote up
/**
 * 获取验证码图片和文本(验证码文本会保存在HttpSession中)
 */
@RequestMapping("getVerifyCodeImage")
public void getVerifyCodeImage(HttpServletRequest request, HttpServletResponse response) throws IOException {
    //设置页面不缓存
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    response.getOutputStream();
    String verifyCode = VerifyCodeImageUtil.generateTextCode(VerifyCodeImageUtil.TYPE_NUM_UPPER, 4, null);

    //将验证码放到HttpSession里面
    request.getSession().setAttribute("verifyCode", verifyCode);
     log.info("本次生成的验证码为:" + verifyCode + ",已存放到HttpSession中");

    //设置输出的内容的类型为JPEG图像
    response.setContentType("image/jpeg");
    BufferedImage bufferedImage = VerifyCodeImageUtil.generateImageCode(verifyCode, 90, 30, 3, true, Color.WHITE, Color.BLACK, null);

    //写给浏览器
    ImageIO.write(bufferedImage, "JPEG", response.getOutputStream());
}
 
Example 2
Source File: SleepingServlet.java    From selenium with Apache License 2.0 6 votes vote down vote up
@Override
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws IOException {
   String duration = request.getParameter("time");
   long timeout = Long.parseLong(duration) * 1000;

   reallySleep(timeout);


   response.setContentType("text/html");
//Dont Cache Anything  at the browser
   response.setHeader("Cache-Control","no-cache");
   response.setHeader("Pragma","no-cache");
   response.setDateHeader ("Expires", 0);

   response.getOutputStream().println(
       String.format(RESPONSE_STRING_FORMAT, duration));
 }
 
Example 3
Source File: CaptchaUtils.java    From xmanager with Apache License 2.0 6 votes vote down vote up
/**
 * 生成验证码
 */
static void generate(HttpServletResponse response, String vCode) {
	BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
	response.setHeader("Pragma","no-cache");
	response.setHeader("Cache-Control","no-cache");
	response.setDateHeader("Expires", 0);
	response.setContentType("image/jpeg");
	
	ServletOutputStream sos = null;
	try {
		drawGraphic(image, vCode);
		sos = response.getOutputStream();
		ImageIO.write(image, "JPEG", sos);
		sos.flush();
	} catch (Exception e) {
		throw new RuntimeException(e);
	} finally {
		IOUtils.closeQuietly(sos);
	}
}
 
Example 4
Source File: ServletWebRequest.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkNotModified(String etag, long lastModifiedTimestamp) {
	HttpServletResponse response = getResponse();
	if (StringUtils.hasLength(etag) && !this.notModified) {
		if (isCompatibleWithConditionalRequests(response)) {
			etag = addEtagPadding(etag);
			this.notModified = isEtagNotModified(etag) && isTimestampNotModified(lastModifiedTimestamp);
			if (response != null) {
				if (this.notModified && supportsNotModifiedStatus()) {
					response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
				}
				if (isHeaderAbsent(response, HEADER_ETAG)) {
					response.setHeader(HEADER_ETAG, etag);
				}
				if (isHeaderAbsent(response, HEADER_LAST_MODIFIED)) {
					response.setDateHeader(HEADER_LAST_MODIFIED, lastModifiedTimestamp);
				}
			}
		}
	}
	return this.notModified;
}
 
Example 5
Source File: FeedMediaDispatcher.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * @param response
 * @param lastModified
 */
private void setrResponseNotModified(final HttpServletResponse response, Date lastModified) {
    // Send not modified response
    response.setDateHeader("last-modified", lastModified.getTime());
    try {
        response.sendError(HttpServletResponse.SC_NOT_MODIFIED);

    } catch (final IOException e) {
        // Send not modified failed
        log.error("Send not modified failed", e);

    }
}
 
Example 6
Source File: ServletUtils.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 设置禁止客户端缓存的Header.
 * 
 * @param response
 *            HttpServletResponse
 */
public static void setDisableCacheHeader(HttpServletResponse response) {
    // Http 1.0 header
    response.setDateHeader("Expires", 1L);
    response.addHeader("Pragma", "no-cache");
    // Http 1.1 header
    response.setHeader("Cache-Control", "no-cache, no-store, max-age=0");
}
 
Example 7
Source File: CaptchaController.java    From dubai with MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public void validateCode(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {

    httpServletResponse.setHeader("Cache-Control", "no-store");
    httpServletResponse.setHeader("Pragma", "no-cache");
    httpServletResponse.setDateHeader("Expires", 0);

    String captchaString = CaptchaUtil.generateString(CaptchaUtil.TYPE_NUM_UPPER, 4, null);
    httpServletRequest.getSession().setAttribute(ShiroConstant.CAPTCHA_SESSION_KEY, captchaString);
    httpServletResponse.setContentType("image/jpeg");
    BufferedImage bim = CaptchaUtil.generateImage(captchaString, 90, 30, 3, true, Color.WHITE, null, null);
    ImageIO.write(bim, "JPEG", httpServletResponse.getOutputStream());
}
 
Example 8
Source File: UtilHttp.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static void setResponseBrowserProxyNoCache(HttpServletResponse response) {
    long nowMillis = System.currentTimeMillis();
    response.setDateHeader("Expires", nowMillis);
    response.setDateHeader("Last-Modified", nowMillis); // always modified
    response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, private"); // HTTP/1.1
    response.setHeader("Pragma", "no-cache"); // HTTP/1.0
}
 
Example 9
Source File: CacheForcingFilter.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
  if (response instanceof HttpServletResponse) {
    HttpServletResponse httpResponse = (HttpServletResponse) response;
    Date now = new Date();
    httpResponse.setDateHeader("Date", now.getTime());
    httpResponse.setDateHeader("Expires", now.getTime() + ONE_MONTH_IN_MILISECONDS);
    httpResponse.setHeader("Pragma", "no-cache");
    httpResponse.setHeader("Cache-control", "public, max-age=" + ONE_MONTH_IN_SECONDS);
  }
  chain.doFilter(request, response);
}
 
Example 10
Source File: ResourceServlet.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Set HTTP headers to allow caching for the given number of seconds.
 *
 * @param response where to set the caching settings
 * @param seconds number of seconds into the future that the response should be cacheable for
 */
private void configureCaching(HttpServletResponse response, int seconds) {
	// HTTP 1.0 header
	response.setDateHeader(HTTP_EXPIRES_HEADER, System.currentTimeMillis() + seconds * 1000L);
	if (seconds > 0) {
		// HTTP 1.1 header
		response.setHeader(HTTP_CACHE_CONTROL_HEADER, "max-age=" + seconds);
	} else {
		// HTTP 1.1 header
		response.setHeader(HTTP_CACHE_CONTROL_HEADER, "no-cache");

	}
}
 
Example 11
Source File: PacController.java    From proxyee-down with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/pd.pac")
public void pac(HttpServletResponse response) {
  response.setHeader("Content-Type", "application/x-ns-proxy-autoconfig");
  response.setHeader("Cache-Control", "no-cache");
  response.setHeader("Pragma", "no-cache");
  response.setDateHeader("Expires", 0);
  try (
      OutputStream out = response.getOutputStream()
  ) {
    out.write(
        pacTemple.replace("{port}", ContentManager.CONFIG.get().getProxyPort() + "").getBytes());
  } catch (Exception e) {
    LOGGER.warn("res error:", e);
  }
}
 
Example 12
Source File: RootServlet.java    From reinvent2013-mobile-photo-share with Apache License 2.0 5 votes vote down vote up
public void sendOKResponse(HttpServletResponse response, String data) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("text/plain; charset=UTF-8");
    response.setDateHeader("Expires", System.currentTimeMillis());

    if (null != data) {
        ServletOutputStream out = response.getOutputStream();
        out.println(data);
    }
}
 
Example 13
Source File: Servlets.java    From dubai with MIT License 5 votes vote down vote up
/**
 * 设置客户端缓存过期时间 的Header.
 */
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
	// Http 1.0 header, set a fix expires date.
	response.setDateHeader(HttpHeaders.EXPIRES, System.currentTimeMillis() + (expiresSeconds * 1000));
	// Http 1.1 header, set a time after now.
	response.setHeader(HttpHeaders.CACHE_CONTROL, "private, max-age=" + expiresSeconds);
}
 
Example 14
Source File: CommonController.java    From jeewx with Apache License 2.0 5 votes vote down vote up
/**
 * 自动完成请求返回数据
 * 
 * @param request
 * @param responss
 */
@RequestMapping(params = "getAutoList")
public void getAutoList(HttpServletRequest request, HttpServletResponse response, Autocomplete autocomplete) {
	String jsonp = request.getParameter("jsonpcallback");
	String trem = StringUtil.getEncodePra(request.getParameter("trem"));// 重新解析参数
	autocomplete.setTrem(trem);
	List autoList = systemService.getAutoList(autocomplete);
	String labelFields = autocomplete.getLabelField();
	String[] fieldArr = labelFields.split(",");
	String valueField = autocomplete.getValueField();
	String[] allFieldArr = null;
	if (StringUtil.isNotEmpty(valueField)) {
		allFieldArr = new String[fieldArr.length+1];
		for (int i=0; i<fieldArr.length; i++) {
			allFieldArr[i] = fieldArr[i];
		}
		allFieldArr[fieldArr.length] = valueField;
	}
	
	try {
		String str = TagUtil.getAutoList(autocomplete, autoList);
		str = "(" + str + ")";
		response.setContentType("application/json;charset=UTF-8");
		response.setHeader("Pragma", "No-cache");
           response.setHeader("Cache-Control", "no-cache");
           response.setDateHeader("Expires", 0);
           response.getWriter().write(JSONHelper.listtojson(allFieldArr,allFieldArr.length,autoList));
           response.getWriter().flush();
           response.getWriter().close();
	} catch (Exception e1) {
		e1.printStackTrace();
	}

}
 
Example 15
Source File: TokenFiltersDataServlet.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
		IOException {
	try {
		ServiceUtil.validateSession(request);

		response.setContentType("text/xml");
		response.setCharacterEncoding("UTF-8");

		// Avoid resource caching
		response.setHeader("Pragma", "no-cache");
		response.setHeader("Cache-Control", "no-store");
		response.setDateHeader("Expires", 0);

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

		ContextProperties config = Context.get().getProperties();

		PrintWriter writer = response.getWriter();
		writer.print("<list>");

		if (StringUtils.isNotEmpty(filter)) {
			// We have to iterate over the configs of a specific filter
			String prefix = "index.tokenfilter." + filter + ".";
			Map<String, String> settings = config.getProperties(prefix);
			for (String setting : settings.keySet()) {
				if (setting.equals("position"))
					continue;
				writer.print("<filter>");
				writer.print("<name><![CDATA[" + setting + "]]></name>");
				writer.print("<value><![CDATA[" + settings.get(setting) + "]]></value>");
				writer.print("</filter>");
			}
		} else {
			// We have to iterate over the filters
			List<String> filters = FilteredAnalyzer.getTokenFilterNames(false);
			for (String filterName : filters) {
				writer.print("<filter>");
				writer.print("<name><![CDATA[" + filterName + "]]></name>");
				if ("enabled".equals(config.getProperty("index.tokenfilter." + filterName)))
					writer.print("<eenabled>0</eenabled>");
				else
					writer.print("<eenabled>2</eenabled>");
				writer.print("</filter>");
			}
		}

		writer.print("</list>");
	} catch (Throwable e) {
		log.error(e.getMessage(), e);
		if (e instanceof ServletException)
			throw (ServletException) e;
		else if (e instanceof IOException)
			throw (IOException) e;
		else
			throw new ServletException(e.getMessage(), e);
	}
}
 
Example 16
Source File: VerifyServlet.java    From blog-sample with Apache License 2.0 4 votes vote down vote up
/**
 * @param request
 * @param response
 * @throws ServletException
 * @throws java.io.IOException
 */
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
    // 定义图像buffer
    BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D gd = buffImg.createGraphics();
    // 创建一个随机数生成器类
    Random random = new Random();
    // 将图像填充为白色
    gd.setColor(Color.LIGHT_GRAY);
    gd.fillRect(0, 0, width, height);
    // 创建字体,字体的大小应该根据图片的高度来定。
    Font font = new Font("Times New Roman", Font.PLAIN, fontHeight);
    // 设置字体。
    gd.setFont(font);
    // 画边框。
    gd.setColor(Color.BLACK);
    gd.drawRect(0, 0, width - 1, height - 1);
    // 随机产生16条干扰线,使图象中的认证码不易被其它程序探测到。
    gd.setColor(Color.gray);
    for (int i = 0; i < interLine; i++) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(12);
        int yl = random.nextInt(12);
        gd.drawLine(x, y, x + xl, y + yl);
    }
    // randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
    StringBuffer randomCode = new StringBuffer();
    int red = 0, green = 0, blue = 0;
    // 随机产生codeCount数字的验证码。
    for (int i = 0; i < codeCount; i++) {
        // 得到随机产生的验证码数字。
        String strRand = String.valueOf(codeSequence[random.nextInt(36)]);
        // 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。
        red = random.nextInt(255);
        green = random.nextInt(255);
        blue = random.nextInt(255);
        // 用随机产生的颜色将验证码绘制到图像中。
        gd.setColor(new Color(red, green, blue));
        gd.drawString(strRand, (i + 1) * codeX, codeY);
        // 将产生的四个随机数组合在一起。
        randomCode.append(strRand);
    }
    // 将四位数字的验证码保存到Session中。
    HttpSession session = request.getSession();
    session.setAttribute("validateCode", randomCode.toString());
    // 禁止图像缓存。
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);

    response.setContentType("image/jpeg");
    // 将图像输出到Servlet输出流中。
    ServletOutputStream sos = response.getOutputStream();
    ImageIO.write(buffImg, "jpeg", sos);
    sos.close();
}
 
Example 17
Source File: AjaxPhaseListener.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public void afterPhase(PhaseEvent event) {
	FacesContext context = FacesContext.getCurrentInstance();
	Application app = context.getApplication();
	ValueBinding binding = app.createValueBinding("#{ForumTool}");
	DiscussionForumTool forumTool = (DiscussionForumTool) binding
			.getValue(context);
	Map requestParams = context.getExternalContext()
			.getRequestParameterMap();

	String action = (String) requestParams.get("action");
	String messageId = (String) requestParams.get("messageId");
	String topicId = (String) requestParams.get("topicId");
	String ajax = (String) requestParams.get("ajax");

	HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
	if ("true".equals(ajax)) {
		try {
			ServletOutputStream out = response.getOutputStream();
			response.setHeader("Pragma", "No-Cache");
			response.setHeader("Cache-Control",
					"no-cache,no-store,max-age=0");
			response.setDateHeader("Expires", 1);
			if (action == null) {
				out.println("FAIL");
			} else if ("markMessageAsRead".equals(action)) {
				// Ajax call to mark messages as read for user
				if (messageId != null && topicId != null) {
					if (!forumTool.isMessageReadForUser(Long.valueOf(topicId),
							Long.valueOf(messageId))) {
						forumTool.markMessageReadForUser(Long.valueOf(topicId),
								Long.valueOf(messageId), true);
						out.println("SUCCESS");
					} else {
						// also output success in case message is read, but
						// page rendered mail icon (old state)
						out.println("SUCCESS");
					}
				}
			}
			out.flush();
		} catch (Exception ee) {
			log.error(ee.getMessage(), ee);
		}
		context.responseComplete();
	}
	;
}
 
Example 18
Source File: VerifyServlet.java    From blog-sample with Apache License 2.0 4 votes vote down vote up
/**
 * @param request
 * @param response
 * @throws ServletException
 * @throws java.io.IOException
 */
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
    // 定义图像buffer
    BufferedImage buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D gd = buffImg.createGraphics();
    // 创建一个随机数生成器类
    Random random = new Random();
    // 将图像填充为白色
    gd.setColor(Color.LIGHT_GRAY);
    gd.fillRect(0, 0, width, height);
    // 创建字体,字体的大小应该根据图片的高度来定。
    Font font = new Font("Times New Roman", Font.PLAIN, fontHeight);
    // 设置字体。
    gd.setFont(font);
    // 画边框。
    gd.setColor(Color.BLACK);
    gd.drawRect(0, 0, width - 1, height - 1);
    // 随机产生16条干扰线,使图象中的认证码不易被其它程序探测到。
    gd.setColor(Color.gray);
    for (int i = 0; i < interLine; i++) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(12);
        int yl = random.nextInt(12);
        gd.drawLine(x, y, x + xl, y + yl);
    }
    // randomCode用于保存随机产生的验证码,以便用户登录后进行验证。
    StringBuffer randomCode = new StringBuffer();
    int red = 0, green = 0, blue = 0;
    // 随机产生codeCount数字的验证码。
    for (int i = 0; i < codeCount; i++) {
        // 得到随机产生的验证码数字。
        String strRand = String.valueOf(codeSequence[random.nextInt(36)]);
        // 产生随机的颜色分量来构造颜色值,这样输出的每位数字的颜色值都将不同。
        red = random.nextInt(255);
        green = random.nextInt(255);
        blue = random.nextInt(255);
        // 用随机产生的颜色将验证码绘制到图像中。
        gd.setColor(new Color(red,green,blue));
        gd.drawString(strRand, (i + 1) * codeX, codeY);
        // 将产生的四个随机数组合在一起。
        randomCode.append(strRand);
    }
    // 将四位数字的验证码保存到Session中。
    HttpSession session = request.getSession();
    session.setAttribute("validateCode", randomCode.toString());
    // 禁止图像缓存。
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);

    response.setContentType("image/jpeg");
    // 将图像输出到Servlet输出流中。
    ServletOutputStream sos = response.getOutputStream();
    ImageIO.write(buffImg, "jpeg", sos);
    sos.close();
}
 
Example 19
Source File: BaseCalendarService.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
protected void handleAccessIcalCommon(HttpServletRequest req, HttpServletResponse res, Reference ref, String calRef)
		throws EntityPermissionException, PermissionException, IOException {

	// Ok so we need to check to see if we've handled this reference before.
	// This is to prevent loops when including calendars
	// that currently includes other calendars we only do the check in here.
	if (getUserAgent().equals(req.getHeader("User-Agent"))) {
		res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
		log.warn("Reject internal request for: "+ calRef);
		return;
	}

	// Extract the alias name to use for the filename.
	List<Alias> alias =  m_aliasService.getAliases(calRef);
	String aliasName = "schedule.ics";
	if ( ! alias.isEmpty() )
		aliasName =  alias.get(0).getId();
	
	List<String> referenceList = getCalendarReferences(ref.getContext());
	Time modDate = m_timeService.newTime(0);

	// update date/time reference
	for (String curCalRef: referenceList)
	{
		Calendar curCal = findCalendar(curCalRef);
		/*
		 * TODO: This null check is required to handle the references 
		 * pertaining to external calendar subscriptions as they are 
		 * currently broken in (at least) the 2 following ways:
		 * 
		 * (i) findCalendar will return null rather than a calendar object.
		 * (ii) getCalendar(String) will return a calendar object that is 
		 * not null, but the corresponding getModified() method returns a
		 * date than can not be parsed.  
		 *  
		 * Clearly such references to need to be improved to make them 
		 * consistent with other types as at the moment they have to be
		 * excluded as part of this process to find the most recent modified
		 * date. 
		 */
		if (curCal == null)
		{	
			continue;
		}
		Time curModDate = curCal.getModified();
		if ( curModDate != null && curModDate.after(modDate))
		{
			modDate = curModDate;
		}
	}
	res.addHeader("Content-Disposition", "inline; filename=\"" + aliasName + "\"");
	res.setContentType(ICAL_MIME_TYPE);
	res.setDateHeader("Last-Modified", modDate.getTime() );
	String calendarName = "";
	try {
		calendarName = m_siteService.getSite(ref.getContext()).getTitle();
		boolean isMyDashboard = m_siteService.isUserSite(ref.getContext());
		if (isMyDashboard){
			calendarName = m_serverConfigurationService.getString(UI_SERVICE, SAKAI);
		}
	} catch (IdUnusedException e) {
	}
	printICalSchedule(calendarName, referenceList, res.getOutputStream());
}
 
Example 20
Source File: VersionsDataServlet.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
		IOException {
	try {
		ServiceUtil.validateSession(request);

		/*
		 * Load some filters from the current request
		 */
		int max = 100;

		try {
			max = Integer.parseInt(request.getParameter("max"));
		} catch (Throwable t) {
		}

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

		response.setContentType("text/xml");
		response.setCharacterEncoding("UTF-8");

		// Avoid resource caching
		response.setHeader("Pragma", "no-cache");
		response.setHeader("Cache-Control", "no-store");
		response.setDateHeader("Expires", 0);

		PrintWriter writer = response.getWriter();
		writer.write("<list>");

		VersionDAO dao = (VersionDAO) Context.get().getBean(VersionDAO.class);

		List<Object> parameters = new ArrayList<Object>();
		StringBuffer query = new StringBuffer(
				"select A.id, A.username, A.event, A.version, A.fileVersion, A.versionDate, A.comment, A.docId, A.fileName, A.customId, A.fileSize, A.type, A.templateName ");
		if (request.getParameter("docId") != null) {
			query.append(" from Version A where A.deleted = 0 and A.docId = ?1 ");
			parameters.add(Long.parseLong(request.getParameter("docId")));
		} else {
			query.append(" from Version A, Archive B where A.deleted = 0 and A in elements(B.entries) ");
			query.append(" and B.id = ?1");
			parameters.add(Long.parseLong(request.getParameter("archiveId")));
		}
		query.append(" order by A.versionDate desc ");

		DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
		df.setTimeZone(TimeZone.getTimeZone("UTC"));

		List<Object> records = (List<Object>) dao.findByQuery(query.toString(), parameters.toArray(new Object[0]),
				max);

		/*
		 * Iterate over records composing the response XML document
		 */
		for (Object record : records) {
			Object[] cols = (Object[]) record;

			writer.print("<version>");
			writer.print("<id>" + cols[0] + "</id>");
			writer.print("<user><![CDATA[" + (cols[1] == null ? "" : cols[1]) + "]]></user>");
			writer.print("<event><![CDATA[" + I18N.message((String) cols[2], locale) + "]]></event>");
			writer.print("<version>" + cols[3] + "</version>");
			writer.print("<fileVersion>" + cols[4] + "</fileVersion>");
			writer.print("<date>" + df.format((Date) cols[5]) + "</date>");
			writer.print("<comment><![CDATA[" + (cols[6] == null ? "" : cols[6]) + "]]></comment>");
			writer.print("<docid>" + cols[7] + "</docid>");
			writer.print("<filename><![CDATA[" + (String) cols[8] + "]]></filename>");
			writer.print("<customid><![CDATA[" + (cols[9] == null ? "" : cols[9]) + "]]></customid>");
			writer.print("<size>" + cols[10] + "</size>");
			writer.print("<icon>" + FilenameUtils.getBaseName(IconSelector.selectIcon((String) cols[11]))
					+ "</icon>");
			writer.print("<type>" + (String) cols[11] + "</type>");
			if (cols[12] != null)
				writer.print("<template><![CDATA[" + cols[12] + "]]></template>");
			else
				writer.print("<template></template>");
			writer.print("</version>");
		}

		writer.write("</list>");
	} catch (Throwable e) {
		log.error(e.getMessage(), e);
		if (e instanceof ServletException)
			throw (ServletException) e;
		else if (e instanceof IOException)
			throw (IOException) e;
		else
			throw new ServletException(e.getMessage(), e);
	}
}