File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I'm trying to send XML to a servlet but the input is always null

 
Gobiraj Vadivelrajan
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Java client which sends XML data to a servlet.
I'm writing string data to the output stream but in the servlet the inputstream is always null.
I'm not sure if I'm missing something.
I'm using tomcat 4 and JDK 1.2.2
Thanks for any help.
Java Client Code

Servlet Code
 
Kevin Black
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www-106.ibm.com/developerworks/java/library/j-tunnel/?dwzone=java
Check the article there, it might be helpful.
Kevin
 
Joe Wilkinson
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I was experiencing the same problem. What I found worked to get the string contents of my post is the following code in the servlet :
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
    ServletRequestWrapper srw = new ServletRequestWrapper(request);
    BufferedReader br = srw.getReader();
    StringWriter sw = new StringWriter();
    int bit=0;
    while ((bit=br.read())>=0){
        sw.write(bit);
    }
    sw.flush();
    String contents = sw.toString();
}
Hope this helps you.
Ciao,
Joe
[ April 24, 2003: Message edited by: Joe Wilkinson ]
[ April 24, 2003: Message edited by: Joe Wilkinson ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic