Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

filter / GenericResponseWrapper cuts of HTML source

 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea why that happens ?
In generaly it works with no problem on any page that I tested so far.
Problematic page (Not filtered): http://agrozoo.net/jsp/a_oglasna_deska.jsp




FILTER



NO FILTER


...
<input type ="button" value ="B" onClick ="loadPdfBlob(388900)" />


<br>


<input type ="button" value ="UPRAVNA ENOTA TRŽIČ" onclick="document.getElementById('pdfFrame').src = '../Uploaded_Oglasna_Deska/387986.pdf'" />26. 1. 2016 (objava do 25. 2. 2016)
<input type ="button" value ="A" onClick ="$.get(contextPath + '/servlets/GetBlobDataServlet',{ u_id:'387986'},function(data){ document.getElementById('pdfFrame').src = data;})"/>

<input type ="button" value ="B" onClick ="loadPdfBlob(387986)" />


<br>


<input type ="button" value ="UPRAVNA ENOTA TRŽIČ" onclick="document.getElementById('pdfFrame').src = '../Uploaded_Oglasna_Deska/382892.pdf'" />8. 1. 2016 (objava do 7. 2. 2016)
<input type ="button" value ="A" onClick ="$.get(contextPath + '/servlets/GetBlobDataServlet',{ u_id:'382892'},function(data){ document.getElementById('pdfFrame').src = data;})"/>

<input type ="button" value ="B" onClick ="loadPdfBlob(382892)" />


<br>


</div>


<div style ="float:left; width:50%;height:100%;background:blue;">
<iframe id ="pdfFrame" style="float:none;display:inline;width:100%;height:100%;border:0px;" src="#"></iframe>
</div>



</body>
</html>



FILTER (cuts stuff off at the end)


...
<input type ="button" value ="B" onClick ="loadPdfBlob(388900)" />


<br>


<input type ="button" value ="UPRAVNA ENOTA TRŽIČ" onclick="document.getElementById('pdfFrame').src = '../Uploaded_Oglasna_Deska/387986.pdf'" />26. 1. 2016 (objava do 25. 2. 2016)
<input type ="button" value ="A" onClick ="$.get(contextPath + '/servlets/GetB"
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A truncated output stream is frequently a matter of an exception being thrown.
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I wrap into try/except - does not go into exception


Further, what you see here http://agrozoo.net/jsp/a_oglasna_deska.jsp (NOT FILTERED)
The list - is from db, if I set limit to 10, all goes fine, no errors, page comes out as it should.
limit 9,11, random picks , nothing gets thru, empty body. If filter deactivated - all ok regardles of random limit pick.
I have whole thing inside try/except in that jsp page, no exceptions.

I'm definitely sure onyl of one thing, if I change, in that jsp

<!DOCTYPE html>


to

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


I get like +/-100 more characters in ouput as result only of that change ...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The doctype is irrelevant.

Nothing in the logs? How do you know the exception is being thrown/caught?
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothin in server logs. That is all I know.

if this provides any insight, I could replace code from GenericResponseWrapper (from first post) with following code but result is the same:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still not convinced that you know that an exception is not being thrown.
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in any case, if someting goes wrong goes in this three lines of code inside filter, and should fall into exception ?



.jsp by itself, as stated before, without going thru filter is OK.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Things can go wrong outside that code, and you're not doing anything in the catch block that's going to give you any insight.

Remove the meaningless try/catch and carefully inspect the logs for exception traces.
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not doing anything in catch because it does not go there anyway. Removed.

1. kill java process
2. delete all log files in apache log
3. restart java, check log files
4. send that jsp thru that filter --> nothing new in apache logs.
5. strOut to short.
 
Dave Tolls
Ranch Hand
Posts: 1908
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stick some logging in your GenericResponseWrapper.
I'd be curious exactly what gets called.

Also, is the html arriving at the client browser that gets cut short, or the bytes that you log, or both?
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

GenericResponseWrapper constructor
setContentType
getWriter
getOutputStream



in that order.

no setContentLength,getContentLength

Probably there somewhere is the prob .... ?


Also, is the html arriving at the client browser that gets cut short, or the bytes that you log, or both?

Both obviously, as page does not display correctly.
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This gets it right.





 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add another opinion here, maybe there is a buffer somewhere that is not being flushed fully?

Your first example had a PrintWriter wrapping a FilterServletOutputStream wrapping a ByteArrayOutputStream (output).
However your toString() method goes directly to that "output" variable.
If content had been written to the PrintWriter but not flushed all the way through then you would see something like this - where it loses the "bottom" of your result.

solution:
Flush the printwriter as part of the toString() method (you will need to keep a reference to the PrintWriter to do this)




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic