LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-29-2004, 08:45 PM   #1
LinuxTiro
Member
 
Registered: Aug 2003
Posts: 59

Rep: Reputation: 15
Exclamation Simple Browser in Java


I need to write a simple Browser in java which takes the following input
<program> -host <ip> -port <port> -url “<required url>”
Output- dump the returned html page on the console
-First level returned content alone is to be displayed
-no further processing frames, redirects, and other complex content

But when i compile my code i dont get the desired output but the following :
Connecting to <HOST IP> on port 8080 HTTP/1.0 400 Bad Request Server: squid/2.5.STABLE5 Mime-Version: 1.0 Date: Fri, 30 Jul 2004 01:23:02 GMT Content-Type: text/html Content-Length: 1196 Expires: Fri, 30 Jul 2004 01:23:02 GMT X-Squid-Error: ERR_INVALID_URL 0 X-Cache: MISS from ProxyServer Proxy-Connection: close

My code is the following
Code:
import java.net.*;
import java.io.*;

public class Browser
{
	public static void main(String args[])
	{
		if(args.length!=3)
		{
			System.out.println("input format  <program> -host <ip> -port <port> -url<required url>");
			System.exit(1);
		}
			int port=Integer.parseInt(args[1]);
			PrintStream out;
			BufferedReader in;
		try
		{
			System.out.println("Connecting to " + args[0] + " on port " + args[1]);
			Socket connection=new Socket(args[0],port);
			out=new PrintStream(connection.getOutputStream());
			in=new BufferedReader(new InputStreamReader(connection.getInputStream()));
			out.println("GET "+args[0]+" HTTP/1.1\n");
			String line = in.readLine();
			while (line != null)
			{
				System.out.println ( line );
			    line = in.readLine();
			}
			connection.close();
		}
		catch (SocketException e )
		{
			System.err.println ("Socket error : " + e);
		}
	}
}
can some1 point out wat is the mistake ?

Last edited by LinuxTiro; 07-29-2004 at 08:47 PM.
 
Old 07-29-2004, 09:08 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
yea you'll get lots of help with that name u tool.
 
Old 07-31-2004, 01:20 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by infamous41md
yea you'll get lots of help with that name u fuckin tool.
First of all, we don't judge others here, we help them. If you have nothing constructive to say or help others, skip it and move on. You made a personal attack and were unconstructive, if you persist, you can lose rights to use these forums and site.

Make this your first but last warning.

If you have a problem with following these rules, feel free to email me, another mod, the admin of the site or simply don't use this site.

http://www.linuxquestions.org/rules.php
 
Old 07-31-2004, 07:24 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
The one who choose such an alias name is the first one who look for trouble, don't blame the shoked.
 
Old 07-31-2004, 07:31 PM   #5
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
Quote:
Originally posted by trickykid
First of all, we don't judge others here, we help them. If you have nothing constructive to say or help others, skip it and move on. You made a personal attack and were unconstructive, if you persist, you can lose rights to use these forums and site.

Make this your first but last warning.

If you have a problem with following these rules, feel free to email me, another mod, the admin of the site or simply don't use this site.

http://www.linuxquestions.org/rules.php
i guess u have some problem with me buddy.. 2 idiotic OP's, 2 justified replies from me, and 2 warnings from u. are you reading the same posts that i am or what? who calls themself HITLER and expects people to be cool with that? i run a bb myself, and i ban on sight ANY user who chooses names like that. as a matter of fact, just today i banned some idiot with the name 'christiankiller'...

ps. i'd rather take this up privately in a PM but we can't send PM's.
 
Old 07-31-2004, 09:38 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by infamous41md
i guess u have some problem with me buddy.. 2 idiotic OP's, 2 justified replies from me, and 2 warnings from u. are you reading the same posts that i am or what? who calls themself HITLER and expects people to be cool with that? i run a bb myself, and i ban on sight ANY user who chooses names like that. as a matter of fact, just today i banned some idiot with the name 'christiankiller'...

ps. i'd rather take this up privately in a PM but we can't send PM's.
I guess the part about "email" I stated you missed if you didn't agree, which is ok, but what you've done is judged others on a forum you don't run or set the rules for, now do you?

But you can run your own forums how you want, we don't judge others by their name, unless its blatantly offending a person on purpose, etc. In which I recall has only happened twice I think, cause the brats didn't agree with a moderator on the forums cause they couldn't simply follow simple rules.

And for the record, I don't have a problem with you but I do have a problem when others that are reporting posts complaining about you and your way of offending them using abusive language towards them when they are here to get Linux help.

My advice if you want to use these forums, ignore their names and help if you want. Don't make a big deal about it, its just a name. If he does follow Hitler, oh well, that's his choice. Or if christiankiller kills Christians.. oh well, let the authorities handle him. But right now our members are here to learn and ask about Linux, not to be judged solely on the name they took. It would be a different story if our Member that goes by Hitler was here to offend others only, but not once I've seen him post anything offensive or anything regarding the Hitler we all know from History class.

Now once again, if you want to continue your own biased and prejudicial thoughts on simple names on a Forum, feel free to email me, any other moderator or the Site Admin himself.

Regards.
 
Old 08-01-2004, 12:23 AM   #7
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
HiTleR: do you get the same error for all sites?
 
Old 08-01-2004, 07:25 AM   #8
LinuxTiro
Member
 
Registered: Aug 2003
Posts: 59

Original Poster
Rep: Reputation: 15
yes i was getting the same error.
but i have identified the mistake, instead of giving
out.println("GET "+args[2]+" HTTP/1.1\n");
i have to give
out.println("GET http://"+args[2]+" HTTP/1.1\n");

Trivial i guess.Is there a better way to do this?
 
Old 08-01-2004, 09:39 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
we don't judge others by their name, unless its blatantly offending a person on purpose, etc.
I agree with you, but that particular name, and there are not that much, is actually offending many persons. I can't believe someone can choose such a name without purpose.

Will you accept a posting from someone calling himself "Usama Bin Laden", and say "it's just a kid's joke, let him play ?"
 
Old 08-01-2004, 09:47 AM   #10
LinuxTiro
Member
 
Registered: Aug 2003
Posts: 59

Original Poster
Rep: Reputation: 15
Hey ,i never choose such a name to hurt ne1's feelings. well if it did i am srry.
can any of the mods change my username to LinuxTiro.
I think this will solve the controversy.Now lets stop discussing abt this name issue and focus on wat this forum is originally meant to be .
 
Old 08-01-2004, 10:59 AM   #11
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by jlliagre
I agree with you, but that particular name, and there are not that much, is actually offending many persons. I can't believe someone can choose such a name without purpose.

Will you accept a posting from someone calling himself "Usama Bin Laden", and say "it's just a kid's joke, let him play ?"
If you want to discuss this further, please email me, another mod or the site admin. Lets get this back on topic please.

And for the record, no, I would care less if someone used that name or any name. I don't prejudge cause well, it could be their real name. I know Bin Laden is a very popular name, I know more than one person in the world has the name Usama or maybe even Saddam and Hussein..

If your going to start prejudging people on a forum for what they call themselves, well, you got some problems to sort our yourself really. I'm here to help people, unless they offend me by posting something offensive or if they created an alias of "trickykid-sucks" cause I closed a thread or told them to stop breaking a rule when they were caught, then I have a problem with them.

So again, lets get the thread back on topic and move on.. if you want to discuss the controversial name and our own forum rules, email me or the admin.

Last edited by trickykid; 08-01-2004 at 06:16 PM.
 
Old 08-01-2004, 11:00 AM   #12
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by HiTleR
Hey ,i never choose such a name to hurt ne1's feelings. well if it did i am srry.
can any of the mods change my username to LinuxTiro.
I think this will solve the controversy.Now lets stop discussing abt this name issue and focus on wat this forum is originally meant to be .
If you really want to change your name, email jeremy and ask him. I'm sure he wouldn't have a problem changing your name, I still see no reason to do so. But its your choice.
 
Old 08-01-2004, 01:43 PM   #13
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
well i respect your opinions, and since this is not my site i'll try to avoid the idiots instead of insulting them.
 
Old 08-01-2004, 06:14 PM   #14
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by infamous41md
well i respect your opinions, and since this is not my site i'll try to avoid the idiots instead of insulting them.
You see, that's the type of response that really isn't needed and comes off as childlike, a 5 year old would respond like that. Its those simple comments you can leave to yourself cause once again your breaking our rules. There is no need for name calling, even if its not a direct attack up on one sole member but apparently many you think of this way that use this site.

I'll ask you once again, keep those types of opinions to yourself and lets once again make this the very last warning or you can take it up with the admin and owner to regain privileges to this site.

No more replies here unless its about the thread and its topic.
 
Old 08-02-2004, 03:16 PM   #15
Jose Muņiz
Member
 
Registered: Jul 2003
Location: Mexico City
Distribution: Slackware 9.1, SuSE 9.1
Posts: 248

Rep: Reputation: 32
Well... I think you should verify whether the input argument contains the http:// part and if not, just add it. Otherwise if they call your project using the http:// thing, you'll have an error too.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java script support for browser The Oate Programming 3 10-20-2005 10:54 PM
Java and Web Browser problems. RHLinuxGUY Linux - Software 1 09-25-2005 11:01 AM
How to run simple CGI program in browser ? amit_28oct Programming 5 03-23-2004 11:43 PM
Browser wanted: plain and simple Dark_Helmet Linux - Software 9 07-24-2003 02:25 AM
simple html browser tda Programming 5 05-20-2002 11:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration