Java...the torture continues

Status
Not open for further replies.
With much wailing and gnashing of teeth, I finally got this pig to work:

http://dl.dropbox.com/u/7330168/WebServer.java
Thanks to google searching and established code in the book I have.

Any assistance I could possibly get has been shot to hell as the TA has no hours that
jibe with my schedule, nothing in the book and google gives "meh" results.

http://dl.dropbox.com/u/7330168/FtpClient.java

I've copied and pasted the http code's beginning, but still don't know where to go after that.

Help!
 
Kalila":33xh6vuv said:
Yeah, this screams "do my home work!".

Yeah, in a way...I've said it often enough: I'm a systems person, not a programmer and most
.edu's think "you all have to be programmers" despite proof of 9+ years of "no, you don't".

Haven't touched java in, what? a year? Couldn't program my way out of a wet paper print-out of
a bag...

The FTP Client is what I need help with, the "fill in the blank code" has me drawing a blank like with the simple Web Server...I don't get it and I had a lot of help just to get that done.

I've run ftp and web servers and taught users how to use clients for them, I just never had
the want to write a client/server at all, much less in java. <shrug>

This is why I have a high amount of respect for those that can and do.

So, yes, I need help with school work that's kicking my butt... the rest of it I'm doing
quite well with (networking class, after all...one of my several sys admin hats).

(I did find some code, strangely called "SimpleFTP.java"....I can actually read it and
comprehend most of it...now just to hammer that code into the appropriate blanks, I think.)
 

Faramir

Ars Legatus Legionis
36,356
Subscriptor
I think the point is, leaving aside that this is homework, linking to an entire source file and saying "this doesn't work" isn't a great way to get help. Formulate what you don't understand / can't get working into succinct questions with only as much code as is needed to demonstrate whatever issues you've identified and people are more likely to be forthcoming.
 
Running around yelling "I don't get it" isn't a very constructive way of posing a question and is a very good way of getting ignored by people who might help you. Its a fairly clear sign that you are trying to get other people to do your thinking for you and haven't yet tried to figure it out on your own.

That being said, the assignment seems very straightforward, replace the question marks with working code. Most of the answers should be in the documentation and failing that, you should be able to Google for working code that will help you out.
 
Fair enough...

I started over again, and I think I get it a little, but a few snags:

http://dl.dropbox.com/u/7330168/FtpClient.java

No main class is found, attempts to insert/make one make matters worse (lotsa red)... chalk one
up for "clueless operator".

But the big thing is the code starting at line 88:
Code:
 currentResponse = sendCommand("EPSV ", 229);
data_port = currentResponse.indexOf("|||");

Am I sending the data port to use, or extracting it from the response?
It looks like I'm extracting based on the log below:
Code:
230 Logged on                                  
SYST                                           
215 UNIX emulated by FileZilla                 
PWD                                            
257 "/" is current directory.                  
TYPE I                                         
200 Type set to I                              
EPSV                                           
229 Entering Extended Passive Mode (|||53958|)

I are confused.
 

Joel_B

Ars Praefectus
4,652
Subscriptor
a_non_moose":10o0c0su said:
But the big thing is the code starting at line 88:
Code:
 currentResponse = sendCommand("EPSV ", 229);
data_port = currentResponse.indexOf("|||");

Am I sending the data port to use, or extracting it from the response?
It looks like I'm extracting based on the log below:

For me, the lines 75 to 108 are commented out. It would help if you upload the file you are talking about...

The first line sends, the second line reads the response.

Have you read the Java Documentation for the String class, specifically for the indexOf method...?
 
Faramir":22nwcrju said:
You need a class with the signature:
public static void main(String argv[])

That constructs an ftpclient object, then calls the methods you've defined in the appropriate order.

Tried putting that in there...netbeans just lights up in red...no matter where the ending brace
is placed. Even based it off the webserver's format and placement...nope, same thing.
 
Joel_B":3ic4cr92 said:
For me, the lines 75 to 108 are commented out. It would help if you upload the file you are talking about...

(move the */ from 111 to 80 back where it belongs)

Joel_B":3ic4cr92 said:
The first line sends, the second line reads the response.


That's how I found out the no main class error (commenting out the offending code), but stumbled on the extractDataPort (method, constructor, whatever the frack it is...) and tried:
Code:
 currentResponse = sendCommand("EPSV ", 229);
            data_port = extractDataPort(currentResponse);

            // connect to the data port 
            Socket data_socket = new controlSocket(host, data_port);
            DataInputStream data_reader = controlReader.read(data_port);
currentResponse and data_port work (or netbeans does not bitch at me) but the formatting of data sockets I've tried read, write, buff and plain socket...nothing.

Joel_B":3ic4cr92 said:
Have you read the Java Documentation for the String class, specifically for the indexOf method...?

That was my first thought until I saw the extract method-thingy
 

Joel_B

Ars Praefectus
4,652
Subscriptor
Some thoughts:
* A ftp server isn't a webserver. Decide what you are talking about and stick to it. If you're not sure of the difference, go and do some research about each.
* Post the actual code you are using. "move the */ from 111 to 80 back where it belongs" won't do what you expect it will.
* Post the error messages you are getting in NetBeans. There's probably one you're over-looking.
* Test your code against third-party clients to see if it works against something known to work.

Start doing these and you will make progress.
 
Quit this class, it's plainly not teaching you anything you need to know (e.g. how to not guess, how to ask meaningful questions, how to solve problems in a sensible way), and I'm not really convinced that you have any interest in remedying any of those things yourself.

The fact that you "got a lot of help" first time around means that you're desperately ill-equipped second time around. This is not a fruitful approach.
 
cannot find symbol: class controlSocket for data_socket

no suitable method for read(int) for data_reader

Down to two errors now. Close.

@Joel_B:
1) Administered both, well aware of the diff.
2) Done.
3) Done (see above)
4) This is a client (almost, kinda-sorta), a server upstairs waiting for a connection to
test it out as soon as it does something aside from aggravating me.

@DrPizza/PeterB:
DING!DING!DING!
Supposed to be an easy class as a former network admin. Class is OK, labs are a blast except
for this programming shizzle. I have not touched java in a year, gave up on programming in
'95/96 because there were more fun things to do and learn my first college go around.
There's more to CS than programming, but the .edu mindset is stuck in that venue.

Hell, the next assignment involves C, which *NONE* of us silly CS majors have touched unless
they are in the working world, CEG (computer engineering) dual majors or engineering majors
or embedded systems people. IOW, < half a dozen in the building.
 

Joel_B

Ars Praefectus
4,652
Subscriptor
a_non_moose":1llpl8fl said:
cannot find symbol: class controlSocket for data_socket

no suitable method for read(int) for data_reader

Now we have the error message, perhaps a line numbers as well...? Class-name would be handy, but there's only two of them so we could guess.

If NetBeans is giving you compilation errors, how are you running this...?

@DrPizza/PeterB:
DING!DING!DING!
Supposed to be an easy class as a former network admin. Class is OK, labs are a blast except
for this programming shizzle. I have not touched java in a year, gave up on programming in
'95/96 because there were more fun things to do and learn my first college go around.
There's more to CS than programming, but the .edu mindset is stuck in that venue.

Hell, the next assignment involves C, which *NONE* of us silly CS majors have touched unless
they are in the working world, CEG (computer engineering) dual majors or engineering majors
or embedded systems people. IOW, < half a dozen in the building.

Ah, a "I'm too bright for my teachers" thread.
 
1) All the network admins I work with are capable of google-coding together something that works. It might not be pretty or maintainable but it does function.

2) We just threw out an intern this year without a job offer solely because he refused to grok simple programming (he was interning in the networking team).

If you want to go anywhere in "systems administration" you had better stop complaining and start learning how to at least write a simple application.

Why are they using Java and C? because they're great for teaching people the basics of programming. If you know the concepts it doesn't matter whether you use C or Perl, you'll be able to hack it.
 
koala":3lhcleo3 said:
Ravensroke":3lhcleo3 said:
Why are they using Java and C? because they're great for teaching people the basics of programming. If you know the concepts it doesn't matter whether you use C or Perl, you'll be able to hack it.

You know what's going to happen after saying that, right...?

Heh not trying to start a holy war, just giving two examples on the opposite sides of the programming language spectrum ;)
 
Apparently the FTP client is supposed to be part of the webserver package.

OK, easy enough.

It is supposed to retrieve a text file and fire up the ftp client. Uh-huh, yeah like I can
make that happen.

Apparently the DataOutputStream is supposed to get responses...damned if I could make it work.

Whole shebang for your amusement.

http://dl.dropbox.com/u/7330168/webserver.zip
 
a_non_moose":c5z85itm said:
@DrPizza/PeterB:
DING!DING!DING!
Supposed to be an easy class as a former network admin.
I don't know what gives you that idea. Network administration is no more related to computer science than it is to home economics.

Class is OK, labs are a blast except
for this programming shizzle. I have not touched java in a year, gave up on programming in
'95/96 because there were more fun things to do and learn my first college go around.
There's more to CS than programming, but the .edu mindset is stuck in that venue.
There is more to CS than programming, but if you cannot program, you cannot do CS.
 
Sorta, DrP... I can program, but it is a snail drag race.

Don't forget there's network, servers, workstation, desktop, not just programming.

I've seen fantastic programmers (students, PhD's) that just flail at the command line, other OSs,
and would not touch networking/s if you paid them. Premise I agree with, your conclusion is dead
wrong.

Raven, read above.

updated, got the controlWriter = new DataOutputStream(controlSocket.getOutputStream());
which is the correct format according to the TA, and none of my four attempts were close.

Updated:
http://dl.dropbox.com/u/7330168/webserver.zip
 
a_non_moose":2kca1gmm said:
Don't forget there's network, servers, workstation, desktop, not just programming.

I've seen fantastic programmers (students, PhD's) that just flail at the command line, other OSs,
and would not touch networking/s if you paid them. Premise I agree with, your conclusion is dead
wrong.

I've seen programmers who could admin a their own server or setup a network and I've seen network admins who could code. Being able to learn new stuff nets you more money in the long run. I understand that this is the whole point of getting a degree; its a piece of paper that proves that you can actually learn and apply new concepts; most of the actual knowledge you pick up will ultimately prove useless.
 

ronelson

Ars Legatus Legionis
21,399
Subscriptor
no suitable method for read(int) for data_reader

Code:
data_port = extractDataPort(currentResponse);

// connect to the data port
Socket data_socket = new controlSocket(host, data_port);
DataInputStream data_reader = controlReader.read(data_port);
I think the error is because you meant "data_socket" intead of "data_port" on the last line. I did not download the code, seems likely though.


I've seen fantastic programmers (students, PhD's) that just flail at the command line, other OSs,
and would not touch networking/s if you paid them. Premise I agree with, your conclusion is dead
wrong.
What does any of this have to do with CS curriculum? I expect CS graduates to know a lot of theory, know how to learn, and probably know a few programming languages. CLI, OS knowledge and networking? Always a bonus, rarely happens.

This is like the time that I complained to my professor in an intro to unix class that we had to debug some Fortran 87. Who gives a shit? If you cannot read code and determine its purpose, you should not be in IT, period. I got over it and the rest of the class was great, got a decent grade in it and learned a lot. And this is from someone who flunked out of college. If I could get over it at 19 and with only one summer of being an internet for real work experience, I am pretty sure you can do it with 9+ years of IT work. Man up.
 

grahamb

Ars Praefectus
3,895
Subscriptor
Don't forget there's network, servers, workstation, desktop, not just programming.

You're confusing Computer Science with IT.

The general public sometimes confuses computer scientists with other computer professionals having careers in information technology, or think that computer science relates to their own experience with computers, which typically involves activities such as gaming, web-browsing, and word-processing. However, the focus of computer science is more on understanding the properties of the programs used to implement software such as games and web-browsers, and using that understanding to create new programs or improve existing ones.
 

jbode

Ars Legatus Legionis
11,752
Subscriptor
a_non_moose":29x3rgsc said:
There's more to CS than programming, but the .edu mindset is stuck in that venue.

Programming is to CS as what algebra is to Mathematics. No, it's not the sum total of the degree, but it is a fundamental component. If you can't or don't want to program, then CS is not a viable degree plan. EOF.
 

jbode

Ars Legatus Legionis
11,752
Subscriptor
Metasyntactic":a8fv630n said:
Faramir":a8fv630n said:
You need a class with the signature:
public static void main(String argv[])

That constructs an ftpclient object, then calls the methods you've defined in the appropriate order.
Shouldn't that be: public static void main(String[] args)?

Or does java allow the [] on the name decl?

It goes both ways AFAIK. I think the preferred style is to have it on the type specifier, though.
 
a_non_moose":12s0cne2 said:
Yeah, in a way...I've said it often enough: I'm a systems person, not a programmer and most
.edu's think "you all have to be programmers" despite proof of 9+ years of "no, you don't".

Wait, are you in a CS program?

Because yeah, you have to be a programmer.

Driving for 9 years doesn't make you a mechanic.
 
Kalila":xcmwht9x said:
Your problem is your attitude. You gotta want to learn the stuff. Otherwise, save yourself the time because you'll make a lousy programmer.

Do something that you enjoy instead.

This is what I'm saying...

I got the FTP Client half-working. I took my lumps and made it known that that was too much,
especially two assignments so close to a midterm.

Close enough for .gov work.
 

ronelson

Ars Legatus Legionis
21,399
Subscriptor
I got the FTP Client half-working. I took my lumps and made it known that that was too much,
especially two assignments so close to a midterm.
So, if you agree with what Kalila says, then listen to the second half of it - "Do something that you enjoy instead." If it is too much, drop out. If you carry on with the class, you are implicitly saying it is not too much.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Close enough for .gov work.

I really wanted to stay out of this but I really have to get two things off my chest after that:

A) You acknowledge your (lack of) utility on a forum devoted to programming...
Think it's just fine to sit in mediocrity[1] so long as you're somewhere you feel it is acceptable to put in such work for a paycheck which, to top it all off, you consider the state to be such an acceptable recipient of this largesse.

Are you expecting us to just do the work for you on this basis? To approve?

B) Whatever degree program you are on is ethically bankrupt if they deem it acceptable to give you a degree on this basis.

1. You likely think you're mediocre, I think you're much worse on the basis of this.
 
a_non_moose":3c2p992d said:
Kalila":3c2p992d said:
Your problem is your attitude. You gotta want to learn the stuff. Otherwise, save yourself the time because you'll make a lousy programmer.

Do something that you enjoy instead.

This is what I'm saying...

I got the FTP Client half-working. I took my lumps and made it known that that was too much,
especially two assignments so close to a midterm.

Close enough for .gov work.

Who told you you are going to graduate?

This is only going to get worse for you.
 
Status
Not open for further replies.