How involved would it be to set up a .jsp page to upload a text file?

Discussion in 'OT Technology' started by DeeVoc, May 5, 2003.

  1. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    This is kind of way beyond the scope of the class I'm taking, so if I can't do it no big deal. However if anyone knows any sites that might already have the code that'd be cool. Something like when you try to attach a file in yahoo mail.
     
  2. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    We had to do this for a project one time. I think we wrote something from scratch, but I can't remember. I know we came back later and found that Struts did it for us. Let me look through some things and see what I can find. ;)
     
  3. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
  4. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    yeah, I just found out from my TA not to worry about it.

    But I've got another question that I'm trying to figure out. Okay, so I'm doing some queries that can have 1 or many results, I'm planning on setting a ceiling of 100. My question is, using the framework you showed me, sending strings to the servlet then more strings to another .jsp page. Can I send an array of strings? It doesn't look like it.

    How could I send that much info in that stucture to the jsp page to be displayed?
     
  5. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Ahh, sorry I just checked the api and it just returns an object so I should be able to get by just fine. Ugh, for some reason I way underestimated how hard querying a bunch of different entities would be.

    But I'll thow in one more question just for the hell of it :o. This one's on dealing with tokenizing files that are delimeted by tabs.

    I've got this enormous ascii file that I figured out is tab delimeted. If I load it via excel it comes out fine all the fields that are null for items show up as null. Now if I try to split it up via java's tokenizer using

    Code:
    while( (temp = in.readLine()) != null )
    	  {
    		st = new StringTokenizer( temp, "\t" );
    		while( st.hasMoreTokens() )
    		  {
    			System.out.print( " \"" + st.nextToken() + " \" ");
    		  }
    	  }
    
    I get the non-null fields fine, but the null fields for specific items don't show up. Is there anyways I can get it to at least produce a "" for a field that isn't there but delimited correctly. Thanks
     
  6. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    You can set objects to session. Hell, I've sent ResultSets with hundreds of rows back via session.
     
  7. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Hmm, I'm not really sure off the top of my head. I haven't done much with the StringTokenizer class. If you want to email me the file I'll be happy to look into it.

    [email protected]
     
  8. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Hey, CM I think I got it. java.sun has some good forums and it turns out I just had to set the tokenizer to return the delimiter as a token as well. Then I just had to look for two consecutive "/t"'s and I could then just let the field be null.

    Don't worry I'm working on being less impulsive about asking advice. I used to be stubborn about help my first two years, not sure what happened :o
     
  9. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Ah, cool.

    Hey man, I like trying to help. The department at school asked if I would be a tutor for newbie Java students next fall. I'm just trying to get some practice. :big grin:
     
  10. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Haha, that's the worst when everyone's just getting started. Kids are going to show up and just be like, "my program doesn't work, why not? can you fix it?".

    I'm almost done, so close I can taste it. I've just gotta work around this stupid fucking windows character that's in some spots of the ascii files. It looks like a rectangle and it gets recognized as a shitload of whitespace. I think it might be a carrige return or something but I'm not sure.
     
  11. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Yeah, I'll get some pretty odd questions I'm sure. But they'll all be 250 students (intro to prog) so their hardest questions will be about OOP and arrays. Not too bad at all.
     
  12. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Here's exaclty what it looks like:
    Code:
    CURRENTLY RECEIVING (1997)v14 nos 2-4: Single issue donation

    edit - Ugh, it doesn't show up cause it's some dumb fucking whitespace code that I'm guessing windows uses and unix interprets as a lot of whitespace.

    edit2 - of course when I edit, it shows up for some reason.
     
  13. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Yeah, but you'll be in the weedout classes where no one realizes they're going to have to figure out alot on their own. My friend did TAing for an into to comp eng class taht we have to take (half adders and crap like that) She got paid nicely and didn't do shit except grade exams.
     
  14. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Yeah, the cool thing about being a tutor is the convenience. I'll have an office in the department, I can make my own hours, and I won't have to go driving off to a job everyday after class. The bad part is the pay. On my consulting work, I get paid more than twice as much as the tutors do at my school. They get around $8-10/hr. My pay isn't amazing, but it's pretty damn good for a 20 year old college geek living at home. As far as fixed bills, all I have is my car, insurance, and cell. Of course gas, food, and a gf aren't exactly cheap. ;)
     
  15. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Yeah I hear you, at least your getting experience though, I'm friggin installing alarms and stereos for best buy. It's fun, but's it's not going to impress anyone on my resume. I've got a final interview on thurs for some perl programming that's a co-op so I may even be able to use it to get credit towards my major. :x:

    Man, this character is really getting to me though. Have you ever dealt with ' ' before? It's really confusing me cause if you type it in any windows program it pops up as whitespace, it prints as whitespace in unix, but java tokenizer doesn't recognize it as whitespace. It even returned to me a token as following that contained it:

    originally:
    Code:
    (1997)v14
    actual token supposedly separated by whitespace:
    Code:
    |(1997)
    	   v14|
     
  16. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    So when your app comes through it shows the space as the square and you want it to show the actual whitespace?
     
  17. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    No, when I open the ascii file in notepad it shows the ' ' character. But if I use cat or I try to process it in my java file it show up as that large amount of whitespace. The whitespace is what I'm trying to get rid of. However, when I tokenize it java doesn't see the ' ' as whitespace and won't split the surround strings accordingly like how I displayed it above in the second code tag. I think this may be an issue with how the ascii files given to us were formatted. The ' ' character doesn't even exist in the unix environment from what I can tell. If I try to paste it into my unix prompt it deletes most of whats on the the current line so I'm guessing it's pasting a goot amount of whitespace or something.
     
  18. DeeVoc

    DeeVoc Heh.

    Joined:
    Aug 13, 2001
    Messages:
    33,124
    Likes Received:
    0
    Location:
    Brooklyn
    Nice, finally got it figured out. There are a bunch of fucked up ascii characters floating around in these files. Vertical tabs and Group separators that have fucked up escape characters. Oh well at least I finally got it out of the way.



    Oh yeah, CM if you check back in here. I managed to pull a sumemr co-op with nasa. Had the official tour the other day and there's some serious shit there :bigthumb:
     
  19. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    Holy shit man, how did you pull that? I'd love to go work for nasa for the summer. :cool:
     

Share This Page