Project

General

Profile

« Previous | Next » 

Revision 39598

fixed problems with encoding

View differences:

modules/uoa-goldoa-portal/trunk/src/main/java/eu/dnetlib/server/CSVServlet.java
14 14
import javax.servlet.http.HttpServletRequest;
15 15
import javax.servlet.http.HttpServletResponse;
16 16
import java.io.IOException;
17
import java.io.OutputStreamWriter;
17 18
import java.io.PrintStream;
19
import java.io.PrintWriter;
18 20

  
19 21
/**
20 22
 * Created by antleb on 10/13/15.
......
40 42
			String mode = req.getParameter("mode");
41 43
			RequestSort requestSortBy = null;
42 44
			RequestSortOrder order = null;
43
			String term = req.getParameter("filterterm");
45
			String term = req.getParameter("filterTerm");
44 46
			Request.RequestStatus[] statusFilter = null;
45 47

  
46 48
			if (req.getParameter("requestSort") != null)
......
53 55

  
54 56
				for (int i = 0; i < statuses.length; i++)
55 57
					statusFilter[i] = Request.RequestStatus.valueOf(statuses[i]);
56
			} else {
58
			} else if ("accounting".equals(mode)){
57 59
				statusFilter = new Request.RequestStatus[] {Request.RequestStatus.APPROVED, Request.RequestStatus.ACCOUNTING_PAID, Request.RequestStatus.ACCOUNTING_ON_HOLD, Request.RequestStatus.ACCOUNTING_DENIED};
58 60
			}
59 61

  
60 62
			String csv = requestManager.getCSV(mode, requestSortBy, order, null, term, statusFilter);
61 63

  
62 64
			resp.setStatus(200);
63
			resp.setContentType("text/csv");
65
			resp.setContentType("text/csv; charset=UTF-8");
64 66
			resp.setContentLength(csv.length());
67
			resp.setCharacterEncoding("UTF-8");
65 68
			resp.addHeader("Content-Disposition", "attachment; filename=requests.csv");
66
			resp.getOutputStream().print(csv);
69
			resp.getWriter().write(csv);
70
//			new PrintWriter(new OutputStreamWriter(resp.getOutputStream(), "UTF-8")).write();
71

  
67 72
		} catch (Exception e) {
68 73
			resp.setStatus(500);
69 74
			e.printStackTrace(new PrintStream(resp.getOutputStream()));

Also available in: Unified diff