Article View: borland.public.jbuilder.java.api
Article #1159Re: How to get content of a text file from client post by web page
From: James Hughes
Date: Wed, 17 Apr 2002 12:51
Date: Wed, 17 Apr 2002 12:51
51 lines
3051 bytes
3051 bytes
It depends on what the client browser does when it submits a form which includes a file input. Most browsers, I believe, will make a multipart request to your server, which means you have to do more work to extract the (binary) form data from the request. First of all, because the browser is sending binary data, you need to get the input stream from the request object, and then you need to decode the bytes retrieved from this input stream. The format for the bytes should conform to (RFC2388) http://www.faqs.org/rfcs/rfc2388.html., which can get quite complicated admittedly, and I have vague memories of seeing some utility classes on the internet somewhere that will decode this information for you. If you simply output each byte as you read it from the stream as if the byte read was a character, then you will see that the form data is formatted as specified by the rfc above, and maybe the rfc will make more sense. Also, have a look at your JSP engine (tomcat?) documentation to see if it deals with 'multipart' form requests. Hope this helps at least a little! J "Angry Orca" <luke@email.newpalm.com> wrote in message news:3cbbece2_1@dnews... > Hi, all: > I encounter a problem here while I am using the jsp. > In the client page, I use this input to post a text file to the server side. > > <p><input type="file" size=40 name="file" value="*.txt"></p> > > On the server side, what should I do to get the content of the file? > The tutorial says this: > To read character data, use the BufferedReader object returned by the > request��s getReader method. To read binary data, use the ServletInputStream > returned by getInputStream. > > But the problem is the construction of BufferedReader need another > inputstream!! What should I do?? > > Thanks a lot for your help. > > -- > *********************** > THE TRUTH IS OUT THERE > *********************** > > >
Technical Details
Message-ID:
<3cbd7021_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!sjc-peer.news.verio.net!news.verio.net!newsfeed.media.kyoto-u.ac.jp!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3cbbece2_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1089d0,6b7f0acc204b911f X-Google-Attributes: gid1089d0,public X-Google-Thread: f74b3,6b7f0acc204b911f X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2002-04-17 06:05:30 PST Reply-To: "James Hughes" <jimbogaz@hotmail.com> From: "James Hughes" <jimbogaz@hotmail.com> Newsgroups: borland.public.jbuilder.java.api,borland.public.jbuilder.java.language References: <3cbbece2_1@dnews> Subject: Re: How to get content of a text file from client post by web page Date: Wed, 17 Apr 2002 13:51:16 +0100 Lines: 53 Organization: Avoca Communications X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 212.161.14.102 Message-ID: <3cbd7021_1@dnews> X-Trace: dnews 1019047969 212.161.14.102 (17 Apr 2002 05:52:49 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!sjc-peer.news.verio.net!news.verio.net!newsfeed.media.kyoto-u.ac.jp!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews