Need to write to the browser proxy [bufferedwriter] [dataoutputstream]

Q: I have a proxy that is connected to the browser and the Internet. Ive set it up where I can block web pages and I need to display a stream of text saying: “403 Forbidden” or something.
I have blocked = new (new Print Writer (outToclient)) / / is a outToclient
I say blocked_message403.write (forbidden_message, 0, forbidden_message.length ());
But this is just a blank page with no text. What am I doing wrong? Any suggestions?
Thanks


Best Answer: i have checked this web site using windows internet explorer,
internet explorer , mozila firefox and opera

everything is working fine with your site


Re:Why did you set Content-Length to 13644?

I count 166 (single byte per character and two bytes per \n). Since you've been writing character data to a byte stream I suspect you'll get two bytes per character (or whatever java's unicode uses). You could try setting the length to something smaller (like 166) and see if the browser gets the document or cuts it short.

A packet sniffer is a program that records every byte that passes through your network card and analyzes it. You can use it to analyze exactly what bytes you're sending over your sockets so you can judge how many characters are in your message.


Re:Well I am printing out the file with that specified code when I send it out to make sure its receiving it all. And it does. What do you mean by packet sniffer?

Re:You might try using a packet sniffer to see what exactly the browser is receiving.

Re:HTTP/1.0 403 Forbidden
Content-Length: 13644
Content-Type: text/html
Cache-Control: private
Set-Cookie: PR
Server: GWS/2.1
Date: Thu, 09 Jun 2005 01:21:48 GMT
Connection: Close

<html>
<title>Dan</title>
<head>Hello</head>
<body>
Forbidden: This page has been blocked by your browser. Contact Admin for further discussion.
</body>
</html>

This is how I changed it but still nothing. I have tried searching google for Content-Length and this is how it is too. Anything else I am leaving out?


Re:Because the browser has no idea if you're done sending data or not. You need a Content-Length header (there's another way but it's more complicated and unneccesary when you've got the whole response in memory like that).

Re:Ok I created an HTML or txt document that included the following:

HTTP/1.0 403 Forbidden
Content-Type: text/html

<html>
<head></head>
<body>
Forbidden: You do not have access to view this page.
</body>
</html>
__________________________________________________ _______

I then create a bufferedreader object.
I then use a while(data = read_forbidden_txt.readLine()) ! = null)
outToclient.writeBytes(data); // outToclient is a

I am getting a blank screen. No text. Why


Re:You can still provide content with a 403 code. Just send back a page like normal, but write the html yourself and have it explain about the error. (And don't forget the Content-Length: header ;) )

Re:Also, it doesn't have to be the message that the HTTP spits out. It can be just plain text. How can I send just a string from the proxy to display in the browser????

Related posts

Leave a comment

0 Comments.

Leave a Reply


click to changeSecurity Code

[ Ctrl + Enter ]