The best place to post a question like this is the Struts USER list 
where there are more people to help you.

-Ted.

zhilei wang wrote:

> I am trying to send  a string from struts action in one application to 
> servlet in another application. However, the following code doesn't work 
> and no string is received. I don't know if it's the problem on sending 
> side or on receiveing side.
> Can someone help me on solving the problem? Thanks.
> 
> Sending side:
> 
> public class SubmitAction extends Action {
>    public ActionForward perform(){
>     String string = " ********";
>     String toURL =
> 
> "http://localhost:8080/AnotherApp/servlet/servlets.ControllerServlet";;
>        URL url = new URL(toURL);
>     URLConnection con = url.openConnection();
>     con.setDoOutput(true);
>     con.setDoInput(true);
>     con.setUseCaches (false);
>        con.setDefaultUseCaches (false);
>     con.setRequestProperty("Content-Type", "text/html");
>     con.setRequestProperty("Content-length", "" + string.length());
>     OutputStream outStream = con.getOutputStream();
>     OutputStreamWriter ostream = new OutputStreamWriter(outStream);
>        BufferedWriter out = new BufferedWriter(ostream);
>        out.write(string);
>        outStream.flush();
>        outStream.close();
>      return new ActionForward(toURL, true);
>    }
> }
> 
> Receiving side:
> 
> public class ControllerServlet extends HttpServlet {
>    public void service(){
>     InputStream in = request.getInputStream();
>     InputStreamReader rdr = new InputStreamReader(in);
>     BufferedReader buff = new BufferedReader(rdr);
>     String line;
>     StringBuffer results = new StringBuffer();
>     while (null != ((line = buff.readLine())))
>         results.append(line + "n");
>     buff.close();
>     String resultString = results.toString();
>    }
> }
> 
> If debug the code, buff.readLine() always return null.
> 
> 
> 
> _________________________________________________________________
> Join the world's largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com
> 
> 
> -- 
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> 


-- 
Ted Husted, Husted dot Com, Fairport NY US
co-author, Java Web Development with Struts
Order it today:
<http://husted.com/struts/book.html>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to