현재 페이지를 캡처하여 pdf로 변환하는 응용 프로그램으로 보내고 싶습니다.자바 웹의 현재 페이지 내용을 캡처하십시오.
FacesContext facesContext=FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)
facesContext.getExternalContext().getResponse();
HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();
// RequestPrinter.debugString();
response.reset();
// download a pdf file
response.setContentType("application/pdf");
response.setHeader("Content-Disposition","attachment;filename="+new Date().toString()+".pdf");
prince.setVerbose(true);
prince.setLog(logFile);
try{
//getPath() to the page the user is currently on
URL pagePath=new URL(this.getPath());
URLConnection urlConnection = pagePath.openConnection();
urlConnection.setDoOutput(true);
int length = urlConnection.getContentLength();
//Lets use inputStream
BufferedInputStream bis=new BufferedInputStream(urlConnection.getInputStream());
response.setContentLength(length);
//this.getPageUsingJSoup().data().getBytes();
//call prince and pass params for inputstream outputStream
prince.convert(bis,response.getOutputStream());
urlConnection.getInputStream().close();
}catch(MalformedURLException mu){
mu.printStackTrace();
}
catch(IOException ioe){
ioe.printStackTrace();
}
facesContext.responseComplete();
웹 사이트가 인증을 필요로하기 때문에이 생성 된 PDF 파일은 loging 오류 페이지입니다 :
이것은 내가 사용하고있는 것입니다.
현재 사용자의 세션을 사용하는 페이지 콘텐츠를 캡처하는 방법이 있습니까?
미리 감사드립니다.
안녕하세요 @BalusC, 우리 webapp은 URL 재 작성을 지원합니다. 먼저 제안을 시도했지만 여전히 오류 로그인 페이지가 표시됩니다. webapp은 Seam 인증을 사용하고 prince (pdf를 인쇄 할 때 사용하는 응용 프로그램)는 Windows 컴퓨터에 설치합니다. 로그인을 통과하거나 새 URL 연결을 인증 된 세션에 바인딩하는 방법이 있습니까? 감사합니다. –
Seam 인증에 익숙하지 않아 자세한 내용을 알 수 없지만 이론적으로는 추가 요청 쿠키가 필요합니다. 일반 웹 브라우저 (Chrome/IE10/Firebug의 F12 키를 누르고 "인터넷"/ "네트워크"섹션을 확인)와 웹 서버간에 HTTP 트래픽을 모니터링하여 요청 헤더에 추가 쿠키가 없는지 확인합니다. 그렇다면 프로그래밍 방식의 요청에서 매우 동일한 쿠키를 시뮬레이션해야합니다. – BalusC
브라우저에서 (캐시를 지우고 다시 로그인 한 후) jsessionid 쿠키 만 있고 세션 저장 공간이 비어 있습니다. tomcat 관리자의 활성 HttpSessions 정보 아래에서 활성 세션에는 세션 이름, 추측 로켈, 추측 사용자 이름, 생성 시간, 마지막 액세스 시간, 사용 시간, 비활성 시간 및 TTL 등의 열 이름이 있습니다. –