Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

servlet input contnet

Thread view: 
odelya - 02 Sep 2007 08:26 GMT
Hi!
I am trying to extract content from ServletInputStream:

ServletInputStream cont = request.getInputStream();
        StringBuffer sb = new StringBuffer();
        BufferedReader br = new BufferedReader(new InputStreamReader(cont));
        sb.append(br.read());
        System.out.println(sb.toString());
        System.out.println(request.getContentLength());

But i get:
-1
-1
Why can't it read it?
odelya - 02 Sep 2007 10:02 GMT
> Hi!
> I am trying to extract content from ServletInputStream:
[quoted text clipped - 10 lines]
> -1
> Why can't it read it?

I would like to add:
what im trying to do, is to get the content when the user clicks on a
link to open the page (not by submitting it)
ohaya - 02 Sep 2007 10:33 GMT
>> Hi!
>> I am trying to extract content from ServletInputStream:
[quoted text clipped - 14 lines]
> what im trying to do, is to get the content when the user clicks on a
> link to open the page (not by submitting it)

Hi,

I think that when they click on a link, which sends an HTTP GET request
to the webserver, there is no "content".  When they do a submit, which
sends an HTTP POST (e.g., submitting a form), then there is "content"
which can be read.

Jim
Lothar Kimmeringer - 02 Sep 2007 11:48 GMT
> I think that when they click on a link, which sends an HTTP GET request
> to the webserver, there is no "content".  When they do a submit, which
> sends an HTTP POST (e.g., submitting a form), then there is "content"
> which can be read.

Nearly ;-) There is only content that can be read, if there
is content being sent. If there is content, will be estimated
with the content-type. With a Content-type of
application/x-www-form-urlencoded (that will be sent if a
form is submitted using POST) I wouldn't expect data that can
be read from the stream, either. The data will be already read
by the surrounding ServletContext to enable use
request.getParameter(...)

But I might be wrong and you should just try it.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

Andrew Thompson - 02 Sep 2007 12:19 GMT
>..you should just try it.

I personally* rate that advice as '10 stars' (out of ten).

( * In case anybody should be even the slightest bit
interested in my opinion of the matter. ;)

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.