HttpServletResponse

R

Rasikow Gnaniyar

I am doing web analytics program in java. I am able to get content
length using request object HttpServletRequest ( for. ex.
hytpReq.getContentLength() )

But I want to get response page's content length. Is there any object
response.getContentLength() using HttpServletResponse? or any idea How
to get Response page's content length?
 
J

Jean-Baptiste Nizet

I am doing web analytics program in java. I am able to get content
length using request object HttpServletRequest ( for. ex.
hytpReq.getContentLength() )

But I want to get response page's content length. Is there any object
response.getContentLength() using HttpServletResponse? or any idea How
to get Response page's content length?

In a servlet, you're supposed to generate the response to a request.
Since you generate the response (by writing to the output stream in
the servlet response), you're supposed to be able to set the content
length in the response by using the setContentLength method.

JB.
 
C

christopher

I am doing web analytics program in java. I am able to get content
length using request object HttpServletRequest ( for. ex.
hytpReq.getContentLength() )

But I want to get response page's content length. Is there any object
response.getContentLength() using HttpServletResponse? or any idea How
to get Response page's content length?

What response? The response you have not created yet? The response
is your output back to the client, so no there is no way for the
container to tell you how long your output is. It is useful for single
objects like images, not so much for pages.

It sounds to me like you are actually writing a bot to query a page
and analyzing the page, then sending your response elsewhere. If that
is the that case you are emulating a client, and you just read the
page in and count the characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top