ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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);
}
}
}
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.
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.
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.
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.
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");
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
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 ?"
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 .
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.