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] how to send a stream to servlet doPost

Thread view: 
边 江 - 14 Sep 2007 06:04 GMT
Hi all:

  I need to send a stream to servle doPost, Now I use
HttpURLConnection to call.

same times is work well, but same times is not work,

the simple code:

            urlCach = new URL("http://192.168.0.88:8080/servlet/SMS");
            urlconCach = (HttpURLConnection)urlCach.openConnection();
            urlconCach.setDoOutput(true);
            urlconCach.setRequestMethod("POST");
            urlconCach.setUseCaches(false);
            urlconCach.setDefaultUseCaches(false);

            CachWriter = new OutputStreamWriter(urlconCach.getOutputStream(),
                    "GB2312");
            CachWriter.write("same xml string");
            CachWriter.flush();
            CachWriter.close();

            urlconCach.getResponseMessage();
            urlconCach.disconnect();
Manish Pandit - 14 Sep 2007 07:00 GMT
On Sep 13, 10:04 pm,     <bord...@gmail.com> wrote:
> Hi all:
>
[quoted text clipped - 20 lines]
>                         urlconCach.getResponseMessage();
>                         urlconCach.disconnect();

Is there any change that causes it to fail, like ASCII vs. binary
data, large vs. small data, browser difference? May be you need to set
the request content type and/or the size. Please provide details on
the cases where it fails vs. passes. If it fails sporadically for the
same data, then it could even be a spotty connection. Also, you can
check and print out the responseCode as well as the response message
(which you are retrieving in the 2nd last line). It might carry some
information too (500?). Check the webserver/container log for any
exceptions or HTTP error codes as well.

-cheers,
Manish
borderj@gmail.com - 14 Sep 2007 14:58 GMT
> Is there any change that causes it to fail, like ASCII vs. binary
> data, large vs. small data, browser difference? May be you need to set
[quoted text clipped - 8 lines]
> -cheers,
> Manish

   It's two different system, One is java application,other is
servlet. use java send a string(xml file < 1M) to servlet,  servlet
find loacle file, return a string(xml file < 1m) .it's base Http
socket.

  When I get the response code, it's 500.

Thanks
GArlington - 14 Sep 2007 15:17 GMT
On 14 Sep, 14:58, <bord...@gmail.com> wrote:
> > Is there any change that causes it to fail, like ASCII vs. binary
> > data, large vs. small data, browser difference? May be you need to set
[quoted text clipped - 17 lines]
>
>  Thanks

Are you trying to say that there are two separate systems
communication with each other (i.e. java application sending requests
to servlet, servlet sending responses to java application), or are you
trying to send the same request to two different systems - one with
servlet and another with java application?
If your case is option 1)java application sending requests to servlet,
servlet sending responses to java application
then you still did not show the differences between your requests or
the data that is being processed by servlet. Maybe the file it is
trying to process causes the error (500 = server [servlet run-time]
error).


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



©2008 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.