2014-08-29 1 views
0

내 오류 페이지에 대한 스택 트레이스를 인쇄하지 않는 것은 다음과 같습니다예외가 NullPointerException이

<div class="hideShow" style="width:99%; text-align: center; display: none;" > 
      <UL><LI> <strong><%=exception%> </strong></LI></UL> 
</div> 

<% 
    ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
    PrintWriter writer = new PrintWriter(bytes, true); 
    exception.printStackTrace(writer); 
    exception.printStackTrace(System.err); 
%> 

그래서 UI에서 내가 NUllPointerException 참조 내 스크립틀릿을하지만 내 콘솔 전체 스택 트레이스를 보여줍니다. UI의 스택 트레이스 전체를 보려면 어떻게해야합니까?

나는 다음과 같은 scriplet 코드,

<div class="hideShow" style="width:99%; text-align: center; display: none;" > 
      <UL><LI> <strong><%=exception.printStackTrace(writer)%> </strong></LI></UL> 
</div> 

을 사용하지만 난 콘솔에서이 오류를 얻을 :

The method print(boolean) in the type JspWriter is not applicable for the arguments (void) 

내가 콘솔에서 볼 널 포인터에 대한 스택 트레이스를 표시하는 방법에 대한 어떤 제안 . 다른 유형의 예외에도 잘 작동합니다.

답변

1

exception.printStackTrace(writer)은 값을 반환하지 않으므로 out으로 인쇄 할 수 없습니다.

<div class="hideShow" style="width:99%; text-align: center; display: none;" > 
      <UL><LI> <strong><%exception.printStackTrace(response.getWriter());%> </strong></LI></UL> 
</div> 
+0

위의 지금이 예외를 얻기를 시도 변경 코드는 – JNPW

+0

당신의 PrintWriter와 괜찮아 "유형의 Throwable의 방법의 printStackTrace (의 PrintStream)는 인수 (JspWriter를) 적용 할 수 없습니다"? –

+0

PrintWrite 객체를 전달했으며이 오류가 발생했습니다. ""JspWriter 유형의 print (boolean) 메서드는 인수 (void)에 적용 할 수 없습니다. "" – JNPW