dcsimg
write a string from URLConnection to a servlet
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   dave_sullins
Posted On:   Wednesday, December 3, 2003 09:29 AM

I'm trying to write a string from URLConnection to a servlet. what I'm trying to do is, get an XML file from client over URL so that the servlet can get it and process it and send the response to the client. The problem, here is I'm not getting the XMLstring to the servlet. I do the >following steps: > > *client side* > 1. create URL corresponding to the servlet > 2. get URLConnection ( url.openConnection() ) > 3. enable output ( connection.setDoOutput(true) ) > 4. get output stream ( connection.getOutputStream() ) > 5. wrap the output stream into PrintWriter > 6. println(string) > 7. flush/close output stream > *server side*    More>>

I'm trying to write a string from URLConnection to a servlet. what I'm trying to do is, get an XML file from client over URL so that the servlet can get it and process it and send the response to the client. The problem, here is I'm not getting the XMLstring to the servlet. I do the
>following steps:
>
> *client side*
> 1. create URL corresponding to the servlet
> 2. get URLConnection ( url.openConnection() )
> 3. enable output ( connection.setDoOutput(true) )
> 4. get output stream ( connection.getOutputStream() )
> 5. wrap the output stream into PrintWriter
> 6. println(string)
> 7. flush/close output stream


> *server side*



> 1. get input stream for the servlet ( request.getInputStream() )
> 2. wrap it to BufferedReader
> 3. read the string
> 4. process it using SAX Parser
> 5. send the response to the client
>It looks like the string has not come
>through to the servlet.

   <<Less

Re: write a string from URLConnection to a servlet

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, December 3, 2003 11:39 AM

I think you have to either put it in the query string and do a GET, or put it in a form parameter and do a POST, to get anything up to the server from the client.

About | Sitemap | Contact